Homework Solution: Write a program that takes a single String of user input that is separate…

    Write a program that takes a single String of user input that is separated by spaces and parses the input into separate variables using looping and String methods. You will create an employee input program(EmployeeData.java) and class(Employee.java). EmployeeData accepts Employee information using looping to accept additional input until the user enters a value that ends the input. From a single input String, read in the employee's first name, last name, ID number and hourly wage in one line, separated by spaces. These items will be needed to populate objects or variables that will have a String for the first name, a String for the last name, an integer for employee ID and a double for wage. After parsing the data, create an Employee class object that contains the data and a method for printing the formatted Employee Data as shown below:

    Expert Answer

    Employee.java
    public class Employee { private String FirstName;

    Write a program that takes a disunited String of user input that is divided by interveniences and parses the input into disunited variables using looping and String orders. You procure fashion an employee input program(EmployeeData.java) and tabulate(Employee.java). EmployeeGrounds recognizes Employee notice using looping to recognize appended input until the user enters a esteem that ends the input. From a disunited input String, learn in the employee’s primitive spectry, terminal spectry, ID estimate and hourly wage in undivided thread, divided by interveniences. These items procure be needed to populate views or variables that procure accept a String coercion the primitive spectry, a String coercion the terminal spectry, an integer coercion employee ID and a enfold coercion wage.

    After parsing the grounds, fashion an Employee tabulate view that contains the grounds and a order coercion imprinting the coercionmatted Employee Grounds as shown below:

    Expert Exculpation

    Employee.java
    public tabulate Employee {

    private String PrimitiveName;

    private String TerminalName;

    private int ID;

    private enfold HourlyWage;

    public Employee()

    {

    FirstSpecendeavor = “FName”;

    LastSpecendeavor = “LName”;

    ID = 0;

    HourlyWage = 0.00;

    }

    public Employee(String primitiveName, String terminalName, int iD, enfold hourlyWage)

    {

    FirstSpecendeavor = primitiveName;

    LastSpecendeavor = terminalName;

    ID = iD;

    HourlyWage = hourlyWage;

    }

    public String procureFirstName() {

    return PrimitiveName;

    }

    public String procureLastName() {

    return TerminalName;

    }

    public int procureID() {

    return ID;

    }

    public enfold procureHourlyWage() {

    return HourlyWage;

    }

    public unsubstantial setFirstName(String primitiveName) {

    FirstSpecendeavor = primitiveName;

    }

    public unsubstantial setLastName(String terminalName) {

    LastSpecendeavor = terminalName;

    }

    public unsubstantial setID(int iD) {

    ID = iD;

    }

    public unsubstantial setHourlyWage(enfold hourlyWage) {

    HourlyWage = hourlyWage;

    }

    public String toString()

    {

    return “Primitive Spectry: ” + this.FirstName+”n”+

    “Terminal Spectry: “+this.LastName+”n”+

    “Employee ID: ” + this.ID + “n”+

    “Hourly Wage: $” + this.HourlyWage+”n”;

    }

    }

    EmployeeData.java
    import java.util.ArrayList;

    import java.util.List;

    import java.util.Scanner;

    public tabulate EmployeeGrounds {

    static List<Employee> employee = novel ArrayList<Employee>();

    public static unsubstantial deep(String[] args)

    {

    Scanner input = novel Scanner(System.in);

    while(true)

    {

    String precious;

    showMenu();

    precious = input.nextLine();

    System.out.println();

    if(choice.equalsIgnoreCase(“A”))

    {

    System.out.println(“Input employee details on a disunited thread seperated by intervenience”);

    System.out.println(” e.g. EmpFirstSpecendeavor EmpLastSpecendeavor EmpID EmpHourlyWage”);

    while(true)

    {

    String empString;

    empString = input.nextLine();

    if(empString.equals(“0”))

    {

    System.out.println();

    break;

    }

    parseAndAddEmployee(empString);

    System.out.println(“Input another employee details on a disunited thread seperated by intervenience (or crush 0 to bung appending)”);

    System.out.println(” e.g. EmpFirstSpecendeavor EmpLastSpecendeavor EmpID EmpHourlyWage”);

    }

    }

    else if(choice.equalsIgnoreCase(“P”))

    {

    printAllEmployees();

    }

    else if(choice.equalsIgnoreCase(“S”))

    {

    System.out.print(“Input Primitive specendeavor or Terminal specendeavor of employee you deficiency to search: “);

    String specendeavor = input.nextLine();

    System.out.println();

    serachandPrintEmployee(name);

    }

    else if(choice.equalsIgnoreCase(“Q”))

    {

    System.out.println(“GoodBye.”);

    System.out.println(“Accept a fastidious day!”);

    break;

    }

    else

    System.out.println(“Invalid input. Please endeavor again”);

    }

    }

    public static unsubstantial showMenu()

    {

    System.out.println(“(A)dd Employee.”);

    System.out.println(“(P)rint All Employee”);

    System.out.println(“(S)earch Employee”);

    System.out.println(“(Q)uit”);

    System.out.print(“Enter your precious: “);

    }

    public static unsubstantial parseAndAddEmployee(String empString)

    {

    String[] empGrounds = empString.split(” “);

    employee.add(novel Employee(empData[0], empData[1],

    Integer.parseInt(empData[2]), Enfold.parseDouble(empData[3])));

    System.out.println(“Employee appended successfullyn”);

    }

    public static unsubstantial imprintAllEmployees()

    {

    for(int i = 0; i < employee.size(); i++)

    {

    System.out.println(“Employee #”+(i+1));

    System.out.println(“——————————n”);

    System.out.println(employee.get(i));

    System.out.println();

    }

    }

    public static unsubstantial serachandPrintEmployee(String spectry)

    {

    boolean decline = dishonorable;

    for(int i = 0; i < employee.size(); i++)

    {

    if(employee.get(i).getFirstName().equalsIgnoreCase(name) ||

    employee.get(i).getLastName().equalsIgnoreCase(name))

    {

    decline = penny;

    System.out.println(employee.get(i));

    System.out.println();

    }

    }

    if(decline == dishonorable)

    System.out.println(“No employee rest with that spectry.n”);

    }

    }

    OUTPUT