Question
import java.util.ArrayList; import java.util.Scanner; public class Salary { public String name; public Double hour; public Double rate; public Double calculate() { return hour * rate;
import java.util.ArrayList; import java.util.Scanner; public class Salary { public String name; public Double hour; public Double rate; public Double calculate() { return hour * rate; } } public class TestSalary { ArrayList employeeArray = new ArrayList(); public void main(String[] args) { Scanner in = new Scanner(System.in); // public void sethighest(double max) // return max; int i = 0; while (true) { Salary s = new Salary(); System.out.print("Enter the name of Employee or Q to exit: "); String n = in.nextLine(); if (n.equalsIgnoreCase("Q")) { return; } else if(n == "R") { // remove name System.out.print("Enter the name of Employee"); String removedEmployee = in.nextLine(); for (Salary sal : employeeArray ) { if(sal.name == removedEmployee) { employeeArray.remove(sal); System.out.print("Its removed !!"); } } } else { // Adding name s.name = n; System.out.print("Enter the number hours worked: "); s.hour = in.nextDouble(); System.out.print("Enter the pay rate per hour: "); s.rate = in.nextDouble(); employeeArray.add(s); } for (Salary salary : employeeArray) { System.out.println("name of Emp" + salary.name); System.out.println("Salary" + salary.calculate()); System.out.println(name + "\t\t" + hour + "\t\t" + salary); } } } } this is my code for the following question how can i fix the errors: Write a program to process employee salaries. Store the full name (foo bar), the number of hours worked, and pay rate of employees using ArrayList objects. You can define an ArrayList for employee names, an ArrayList for hours, etc. We also need to be able to store the employee pay by calculating pay (hours * rate). MUST use MRETHODS!!! Theyre ideal for this project. a) Prompt the user to enter some data for a list of potential employees. Of course, you need a loop to keep asking the user to enter data. The user should be able to enter as many data records as she wishes. b) Create a new array list to hold the pay for each employee. c) Display the size of the array lists. Make sure to be very descriptive in your output. d) Ask the user to enter the name of an employee and check if the person exists in the array list. Your search must be case insensitive. Display the message EMPLOYEE found, if the name is found in the list and display the employees corresponding employee information (name, hours, rate, and pay). Otherwise, display EMPLOYEE NOT found. EMPLOYEE is the name of the person. So, if the input for name is Foo Bar, well display something like foo Bar, 10 20 200. If the input for name is Bill Bob, well display something like Bill Bob NOT found, if we dont have an employee named Bill Bob. e) Allow the user to add more names. f) Allow the user to remove names. If the name to be removed cannot be found, display an error message. g) Display the name of the employee with the highest salary. h) Display the data in a tabular format (name, hours, rate, and pay)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started