Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

Is an r of 0.90 stronger than an r of 0.50? Explain.

Answered: 1 week ago

Question

c. How is trust demonstrated?

Answered: 1 week ago

Question

Have issues been prioritized?

Answered: 1 week ago

Question

d. How will lack of trust be handled?

Answered: 1 week ago