Question: Hi, I am working on a java assignment in java programming. The assignment is called WriteEmployeeList. The code looks fine; it prompts me the information;

Hi, I am working on a java assignment in java programming. The assignment is called WriteEmployeeList. The code looks fine; it prompts me the information; but does not display the information once you type 999 to quit. Here is my code for the assignment so far:

import java.io.File;

import java.io.PrintWriter;

import java.util.Scanner;

public class WriteEmployeeList

{

public static void main(String[] args)

{

String fileName = "employeeData.txt";

Scanner scanner = new Scanner(System.in);

PrintWriter writer = null;

String delimiter = ",";

String s;

int id;

String firstName;

String lastName;

final int QUIT = 999;

try

{

writer = new PrintWriter(new File(fileName));

System.out.print("Enter employee ID number >> ");

id = Integer.parseInt(scanner.nextLine());

while(id != QUIT)

{

System.out.print("First name >> ");

firstName = scanner.nextLine();

System.out.print("Last Name >>> ");

lastName = scanner.nextLine();

s = id + delimiter + firstName + delimiter + lastName;

writer.println(s);

System.out.print("Enter next ID number or " + QUIT + "to quit");

id = Integer.parseInt(scanner.nextLine());

}

writer.close();

}

catch(Exception e)

{

System.out.println("Message: " + e);

}

}

}

what I have to do is make a program that accepts a series of Employee ID numbers, first names, and last names and save it to a file. When executed, I am supposed to enter the multiple records that display the same first name.

Here is my txt file:

Employee ID number: 100 Employee First Name: john Employee Last Name: sundar Employee ID number: 101 Employee First Name: john Employee Last Name: shekar Employee ID Number: 102 Employee First Name: john Employee Last Name: watson Employee ID number: 103 Employee First Name: kim Employee Last Name: john

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!