wafflehammer
Fully Optimized
- Messages
- 2,502
- Location
- Logan, WV
Code:
A company pays its employees in one of three ways:
a) Salaried workers earn a fixed amount each week regardless of how many hours they work
b) Hourly workers earn $10.00 per hour and they earn time-and-a-half overtime (i.e., $15.00 per hour) for any hours worked beyond 40
c) Part time workers earn $8.00 per hour and are not paid overtime regardless of hours worked
You're going to write an interface and three classes that conform to this interface. You'll also write a class to test your code. Be sure to document the public interface of your code (per section 3.3 in the text).
1. Write an interface called Payday that specifies two abstract methods:
a. findEarnings that has no parameters and returns a double
b. payStub that has no parameters and returns a String
2. Write a class called SalariedEmployee that implements Payday:
a. Member variables are employee ID (String) and salary (double)
b. Methods:
i. a constructor
ii. payStub that returns “Salaried†followed by employeeID and salary
iii. findEarnings that calculates earnings for salaried employees as described in the introductory paragraph
3. Write a class called HourlyEmployee that implements Payday:
a. Member variables are employee ID (String) and hoursWorked (double)
b. Methods:
i. constructor
ii. payStub that returns “Hourly†followed by hours worked followed by ID and pay
iii. findEarnings (as described in the introductory paragraph)
4. Write a class called PartTimeEmployee that implements Payday:
a. Member variables are employee ID (String) and hoursWorked (double)
b. Methods:
i. constructor
ii. payStub that returns “Part Time†followed by hours worked followed by ID and pay
iii. findEarnings (as described in the introductory paragraph)
5. Write a test program that implements the following menu:
1. Add Salaried Employee
2. Add Hourly Employee
3. Add Part Time Employee
4. Display All
5. Quit
6. Display this menu using a while loop to allow the user to loop until the Quit option is selected.
7. Declare an ArrayList (for example myList) of type Payday.
8. If the user enters option 1, ask the user for the employees Id and salary. Create an instance of a SalariedEmployee and add it to the ArrayList. Options 2 and 3 should be handled similarly.
9. For menu option 4, use a for loop to cycle through the ArrayList and print the payStub for each element in the ArrayList:
for(int i=0; i < myList._______; i++)
System.out.println(myList.______.payStub());
10. Obtain user input by means of the Scanner class. To avoid the null buffer problem, obtain numeric values using the Double wrapper class, as in:
System.out.print("Enter name: ");
String name = myScanner.nextLine();
System.out.print("Enter hours worked: ");
double hours = Double.parseDouble(myScanner.nextLine());;
what does 1 actually mean? so far this semester they keep "going over" stuff that we haven't even learned yet and it's getting insanely hard
After that I have no clue about the "findearnings" part of any of those..i get the rest..but not that part...and part 5 I can do because they've actually taught us that :|
any help is appreciated...