Write a program named Personnel that maintain wage information for the employees
ID: 3624874 • Letter: W
Question
Write a program named Personnel that maintain wage information for the employees of a company. The following example shows what the user will see during a session with the program:You are to design a GUI to show the options.
Commands: n- New employees
p- Compute paychecks
r- Raise wages
q- Quit
Enter command: n
Enter name of new employee: Plumber, Phil
Hourly (h) or salaried (s): h
Enter hourly wage: 40.00
Commands: n- New employees
p- Compute paychecks
r- Raise wages
q- Quit
Enter command: n
Enter name of new employee: Coder, Carol
Hourly (h) or salaried (s): s
Enter annual salary: 80000
Commands: n- New employees
p- Compute paychecks
r- Raise wages
q- Quit
Enter command: p
Enter number of hours worked by Plumber, Phil: 50
Pay: $2200.00
Enter number of hours worked by Coder, Carol: 50
Pay: $ 1538.46
Commands: n- New employees
p- Compute paychecks
r- Raise wages
q- Quit
Enter command: r
Enter percentage increase: 4.5
New Wages
--------------------
Plumber, Phil $41.80/hour
Coder, Carol $ 83600.00/year
Commands: n- New employees
p- Compute paychecks
r- Raise wages
q- Quit
Enter command: q
This program will repeatedly prompt the user to enter commands, which it then executes. The program will not terminate until the user enters the command q. Note that the list of commands is redisplayed after each command has been executed.
Write three classes that store information about an employee:
1. Employee (abstract). Instances of this class will store an employee name(a string) and the employee’s hourly wage (a double value.) Methods will include getters and setters for the name and hourly wage, a method that increases the hourly wage by a given percentage, and an abstract method name computePay that computes the weekly pay for the employee when given the number of hours worked.
2. HourlyEmployee, which extends Employee. The constructor will take a name and hourly wage as its parameters. Methods will include computePay and toString. To determine the employee’s pay, computePay mulitplies the first 40 hours (or ferwer) by the employee’s hourly wage. Hours worked beyond 40 are paid at time-and-a-half (1.5 times the hourly wage). toString returns a string containing the employee’s name and hourly wage, formatted as shown in the example of the r command.
3. SalariedEmployee, which extends Employee. The constructor will take a name and annual salary as its parameters. Methods will include a getter and a setter for the annual salary, along with computePay and toString. (Note that the salary will need to be converted to an hourly wage, because that’s what the Employee class requires. To do this conversion, assume that a salaried employee works a 40 hours a week for 52 weeks.) comptePay always returns 1/52 of the annual salary, regardless of the number of hours worked. toString returns a string containing the employee’s name and annual salary, formatted as shown in the example of the r command.
Use an array to store the employee records. Each element of the array will store a reference to an HourlyEmployee object or a SalariedEmployee object. The array used to store employee objects has a maximum size of 50 elements.
• All user input may be preceded or followed by spaces. Commands may be entered as uppercase or lowercase letters. If the user enters a command other than n,p,r or q, the program must display the following message:
Command was not recognized; please try again.
• When asked if the employee is hourly or salaried, the user must enter either h or s(case doesn’t matter). If the user enters any other input, the program must display the following message:
Input was not h or s; please try again.
_____________________________________________________________________________
this is what i have so far i am stuck with the array and last part of the question........
public abstract class Employee
{
protected String name;
protected double hrlywage;
//CONSTRUCTOR
public Employee (String n, double hw)
{
this.name = n;
this.hrlywage = hw;
}
//GETTERS
public String getname()
{
return name;
}
public double gethrlywage()
{
return hrlywage;
}
//SETTERS
public void setname(String n)
{
name = n;
}
public void sethrlywage (double hw)
{
hrlywage=hw;
}
// method that increases hourly wage when a given percentage is received
public double increasehrwage(double p)
{
double hw = hrlywage*p;
return hw;
}
// abstract method that calculates pay
public abstract void computepay(int hrs);
}
..............................................................................................
public class HourlyEmployee extends Employee
{
//constructor
public HourlyEmployee (String n, double hw)
{
super(n,hw);
}
// method that computes pay from the abstract method computepay
public void computepay(int hrs)
{
if(hrs<=40)
{
double empay= gethrlywage()*hrs;
}
else if (hrs>40)
{
double empay = gethrlywage()*hrs*1.5;
}
}
//to string method that returns the name and hourly wage
public String tostring()
{
return ("Employee Name"+name+"Hourly Wage"+hrlywage);
}
}
.....................................................................................................
public class SalariedEmployee extends Employee
{
//Instance variable
private double annualsal;
//Constructor
public SalariedEmployee (String n, double hw, double as)
{
super(n,hw);
this.annualsal = as;
}
//Getter
public double getannualsal()
{
return annualsal;
}
//Setter
public void setannualsal(double as)
{
annualsal = as;
}
//method that calculate the annual salary using the abstract method compute pay in the parent class
public void computepay(int hrs)
{
double sal = (1/52)*annualsal;
}
//to string method
public String tostring()
{
return ("Employee name"+name+"Annual Salary"+annualsal);
}
}
Explanation / Answer
hey did you even got the main class ??
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.