Question: Task 10E: If the user selects Add, the application must be modified to prompt the user for appropriate employee information and set the specific information

Task 10E: If the user selects Add, the application must be modified to prompt the user for appropriate employee information and set the specific information using the mutator methods you created in Task 8D.

Task 10F: Run the EmployeeApp, choose . The object references are displayed on the screen. Add a toString method to the Employee class which returns a formatted string pertaining to the employee information. Play with returning different formatted strings, this choose when running the application. This will demonstrate how this method controls the format of the employee object. String toString()

Task 10G: If you choose Edit from the EmployeeApp, the application will prompt for a last name. The application will do a comparison of this last name to each employee object. Add a equals method to the Employee class which accepts the last name String that was entered from the menu and return either true or false. This method will compare the object last name variable (this.lastName) with the last name that was prompted for in the application. If the names match, return true. If the names do not match, return false. public Boolean equals( String name )

Im having trouble in task 10e where I have to prompt and set the objects.

here is the code i have so far:

package employeeapp; import java.util.Scanner; class Employee { private String firstName; private String lastName; private int employeeId; private double salary; /* Task 10C: Add three constructors */ public Employee(){ } public Employee( String last, String first ) { } public Employee( String last, String first, int id, double wage ){ }

/* Task 10D: Add set (mutator) and get (accessor) meethods*/

public String getFirstName() { return firstName; }

public void setFirstName(String firstName) { this.firstName = firstName; }

public String getLastName() { return lastName; }

public void setLastName(String lastName) { this.lastName = lastName; }

public int getEmployeeId() { return employeeId; }

public void setEmployeeId(int employeeId) { this.employeeId = employeeId; }

public double getSalary() { return salary; }

public void setSalary(double salary) { this.salary = salary; } /*Task 10F: Add toString method */

@Override public String toString() { return "Employee{" + '}'; }

/* Task 10G: Add equals method */ @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Employee other = (Employee) obj; return true; }

}public class EmployeeApp { public static final int MAX_EMPLOYEES = 5; public static void main(String[] args) { Scanner keyboard = new Scanner( System.in );

Employee[] employees = new Employee[MAX_EMPLOYEES]; Employee currentEmployee; String inputString; int inputInt; double inputDouble; char choice; int empCount=0; employees[empCount++] = new Employee( "Mitchum", "Robert", 120402, 34000.0 ); employees[empCount++] = new Employee( "Ryan", "Cornelius" ); employees[empCount++] = new Employee( "Asimov", "Isaac" ); do {System.out.println( " Enter Selection ===============" ); System.out.println( "A> Add new Employee" ); System.out.println( "E> Edit Employee" ); System.out.println( "L> List Employees" ); System.out.println( "Q> Quit" ); System.out.print( " Select: " ); inputString = keyboard.nextLine(); choice = inputString.toUpperCase().charAt( 0 ); System.out.println(); switch( choice ) {case 'A': if ( empCount < MAX_EMPLOYEES-1 ) { // Create object for new Employee employees[empCount] = new Employee(); employees[empCount] = new Employee(); // Task 8E: Prompt for user information and set the object System.out.print("Enter First name" ); System.out.print("Enter Last name" ); System.out.print("Enter Employee Id" ); // parameters via the mutator methods empCount++; } keyboard.nextLine(); break; case 'E': System.out.printf( "Enter Last Name of Employee to Edit: " ); inputString = keyboard.nextLine(); for ( int lp=0; lp

while( choice != 'Q' ); } }

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!