Menu

[Solved]Java Program Help M Fairly New Java M Trying Complete Program Described Program S Returni Q37052665

Java Program Help:

I’m fairly new to Java and I’m trying to complete the programdescribed below. I have my program and it’s returning a couple oferrors and I’m not sure how to fix them. Please help!

2. Employee Management System This exercise assumes that you have created the Employee class for Exercise 1. Create a program

Here is the Employee.java file mentioned for the aboveprogram

1 public class Employee fi 2 private String name, id; public Employee ) 4 public Employee (String name, String id)t this.name

Finally here is my code:

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

import java.util.Scanner;

//import org.apache.commons.collections.collectionUtils;

public class ManagementSystem extends Employee{

  Scanner input = new Scanner(System.in);

  

  public void Menu() {

    System.out.println(“Please Select anOption: “);

    System.out.println(“1. Look UpEmployee”);

    System.out.println(“2. Add a newEmployee”);

    System.out.println(“3. Change anExisting Employee’s ID”);

    System.out.println(“4. Delete anEmployee”);

    System.out.println(“5. Quit”);

    int choice = input.nextInt();

    List<Employee> list =User_Choice(List<Employee>, int choice);

    

    //if (CollectionUtils.isNotEmpty(list)){

    //  Menu(EmployeeList);

    //}

  }

  

  public List<Employee>User_Choice(List<Employee> EmployeeList, int choice){

    if (choice ==1) {

      //int count = 0;

      //System.out.println(“AvailableID’s: “);

      //for (employee emp :employeeList) {

      //  System.out.println(employee.getEmployee_id());

      //}

      System.out.println(“Enter anID to search for: “);

      String search =input.next();

      for (Employee worker :EmployeeList) {

        if(worker.getID() == search) {

          System.out.println(“Name:” + worker.getName());

          System.out.println(“ID:” + worker.getID());

        }

      }

      return EmployeeList;

    }

    if (choice == 2) {

      Employee newWorker = newEmployee();

      System.out.println(“Enter aNew Employee Name: “);

      String name =input.next();

      newWorker.setName(name);

      System.out.println(“Enter aNew Employee ID: “);

      String id =input.next();

      newWorker.setID(id);

      System.out.println(“EmployeeAdded to List”);

      EmployeeList.add(newWorker);

      

      System.out.println(“NewEmployee Info Entered:”);

      System.out.println(“EmployeeName:” + name);

      System.out.println(“EmployeeID:” + id);

      return EmployeeList;

    }

    

    if (choice == 3) {

      System.out.println(“Enter anEmployee’s ID to Replace With a New One: “);

      String old_id =input.next();

      System.out.println(“EnterThe New ID: “);

      String new_id =input.next();

      Employee temp = newEmployee();

      for (Employee worker :EmployeeList){

        if(worker.getID() == old_id) {

          worker.setID(new_id);

          temp= worker;

        }

      }

      System.out.println(“EmployeeID changed, New Employee: “);

      System.out.println(“EmployeeName: ” + temp.getName());

      System.out.println(“EmployeeID: ” + temp.getID());

      return EmployeeList;

    }

    if (choice == 4){

      System.out.println(“Enter anID to be delete: “);

      String id =input.next();

      Employee temp = newEmployee();

      Iterator <Employee>EmployeeIterator = EmployeeList.iterator();

      

      while(EmployeeIterator.hasNext()){

        temp =EmployeeIterator.next();

        if (temp.getID()== id){

          EmployeeIterator.remove();

        }

      }

      System.out.println(“Employeedeleted”);

      return EmployeeList;

    }

    if (choice == 5) {

      System.out.println(“QuittingProgram”);

      System.exit(0);

    }

    return EmployeeList;

  }

  

  public static void main(String [] args){

    

    ManagementSystem ms = newManagementSystem();

    ms.Menu();

  }

    

}

2. Employee Management System This exercise assumes that you have created the Employee class for Exercise 1. Create a program that stores Employee objects in an ArrayList. The program should present a menu that lets the user perform the following actions: Lookup an employee in the list . Add a new employee to the list Change an existing employee’s ID in the list Delete an employee from the list ‘ Quit the program For testing the actions, the program should have two dummy employee entries in the list when the program starts 1 public class Employee fi 2 private String name, id; public Employee ) 4 public Employee (String name, String id)t this.name-name; this.id – id; 7 10 public void setName(String name){ this.name-name; 12 13 14 15 16 17 18 19 20 21 public String getName ) return name; public void setID(String id) this.id – id; public String getID) return id; 23 24 Show transcribed image text 2. Employee Management System This exercise assumes that you have created the Employee class for Exercise 1. Create a program that stores Employee objects in an ArrayList. The program should present a menu that lets the user perform the following actions: Lookup an employee in the list . Add a new employee to the list Change an existing employee’s ID in the list Delete an employee from the list ‘ Quit the program For testing the actions, the program should have two dummy employee entries in the list when the program starts
1 public class Employee fi 2 private String name, id; public Employee ) 4 public Employee (String name, String id)t this.name-name; this.id – id; 7 10 public void setName(String name){ this.name-name; 12 13 14 15 16 17 18 19 20 21 public String getName ) return name; public void setID(String id) this.id – id; public String getID) return id; 23 24

Expert Answer


Answer to Java Program Help: I’m fairly new to Java and I’m trying to complete the program described below. I have my program and … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *