1. Define an abstract super class called Employee that contains a name (String), a social security...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Define an abstract super class called Employee that contains a name (String), a social security number (String) and the respective accessor and mutator functions. Include a two-parameter constructor. It should also contain a toString method whose task is to return the employee's name and social security number (in that order) and an equals method (two employees are equal if they have the same social security number, regardless of type). The Employee class should also declare an abstract getCalculatedSalary method which will be used to calculate the total salary in the derived classes. 2. Next, derive a class called HourlyEmployee to store two data members the hourly rate (double) and the number of hours (double). Provide corresponding constructor and accessors and mutators. Create a method to compute the overtime amount. The overtime is calculated when an employee works more than 40 hours, the extra hours (>40) are paid at one and one half times the employee's regular hourly rate. Include a toString function that must return a String containing the name, social security number, hourly rate, hours, overtime amount and total weekly salary. It will need to call the super class toString. Please include the data formatting as listed on the sample output. 3. Next, derive a class called Salaried Employee to store two data members: the bonus rate (double) and the yearly salary (double). Provide corresponding constructor and accessors and mutators. Create a method to compute the bonus amount based on the bonus percentage and the yearly salary. Include a toString function that must return a String containing the name, social security number, bonus rate, base salary, bonus amount and total annual salary. It will need to call the super class toString. Please include the data formatting as listed on the sample output. 4. In order to hold all employees, create a class called EmployeeList that is able to hold any number of Employees references. EmployeeList should have an ArrayList of Employee as its data member. Create a method to provide the capability to add an employee. An employee must not be added if it has a duplicate social security number. Display an error message if a duplicate is found. Please see example of the error message below: ERROR - Employee Not Added: (display the name of the employee) Duplicate SSN: (display the duplicate SSN). Include a toString function that displays the total number of employees on the list like the following: There are (number of employees) employees on the list It should also display the entire Employee List. Please include the data formatting as displayed on the sample output. Sample Output with sample data: ERROR - Employee Not Added: John Duplicate SSN: 111-00-0000 There are 2 employees on the list. Name: Albert SSN: 111-00-0000 Hourly Rate: $10.50 Hours: 40.00 Overtime Amount: $0.00 Total Weekly Salary: $420.00 Name: Peter SSN: 222-00-0000 Bonus Rate: 10% Base Salary: $50,000.00 Bonus Amount: $5,000.00 Total Annual Salary: $55,000.00 You must use the provided data on the main method. Please DO NOT CHANGE THE MAIN METHOD All classes, methods, calculations and data elements must be properly documented as discussed in class. Please use the main method for the main class below: public class Asg4YourName { } public static void main(String[] args) { } EmployeeListr = new EmployeeList(); r.add(new Hourly Employee("Jim", "400-00-0000", 15.60, 50)); r.add(new Salaried Employee("Alex", "500-00-0000", 81090, .05)); r.add(new Salaried Employee("Tim", "700-00-0000", 111577, .08)); r.add(new Hourly Employee("Mark", "600-00-0000", 21.75, 60)); r.add(new Hourly Employee("Bill", "100-00-0000", 30.00, 45)); r.add(new SalariedEmployee ("Bob", "200-00-0000", 61090, 02)); r.add(new Salaried Employee("Joe", "300-00-0000", 31690, .10)); r.add(new Hourly Employee("Jane", "700-00-0000", 25.50, 60)); r.add(new HourlyEmployee("Emma", "800-00-0000", 12.50, 30)); System.out.println(r); 1. Define an abstract super class called Employee that contains a name (String), a social security number (String) and the respective accessor and mutator functions. Include a two-parameter constructor. It should also contain a toString method whose task is to return the employee's name and social security number (in that order) and an equals method (two employees are equal if they have the same social security number, regardless of type). The Employee class should also declare an abstract getCalculatedSalary method which will be used to calculate the total salary in the derived classes. 2. Next, derive a class called HourlyEmployee to store two data members the hourly rate (double) and the number of hours (double). Provide corresponding constructor and accessors and mutators. Create a method to compute the overtime amount. The overtime is calculated when an employee works more than 40 hours, the extra hours (>40) are paid at one and one half times the employee's regular hourly rate. Include a toString function that must return a String containing the name, social security number, hourly rate, hours, overtime amount and total weekly salary. It will need to call the super class toString. Please include the data formatting as listed on the sample output. 3. Next, derive a class called Salaried Employee to store two data members: the bonus rate (double) and the yearly salary (double). Provide corresponding constructor and accessors and mutators. Create a method to compute the bonus amount based on the bonus percentage and the yearly salary. Include a toString function that must return a String containing the name, social security number, bonus rate, base salary, bonus amount and total annual salary. It will need to call the super class toString. Please include the data formatting as listed on the sample output. 4. In order to hold all employees, create a class called EmployeeList that is able to hold any number of Employees references. EmployeeList should have an ArrayList of Employee as its data member. Create a method to provide the capability to add an employee. An employee must not be added if it has a duplicate social security number. Display an error message if a duplicate is found. Please see example of the error message below: ERROR - Employee Not Added: (display the name of the employee) Duplicate SSN: (display the duplicate SSN). Include a toString function that displays the total number of employees on the list like the following: There are (number of employees) employees on the list It should also display the entire Employee List. Please include the data formatting as displayed on the sample output. Sample Output with sample data: ERROR - Employee Not Added: John Duplicate SSN: 111-00-0000 There are 2 employees on the list. Name: Albert SSN: 111-00-0000 Hourly Rate: $10.50 Hours: 40.00 Overtime Amount: $0.00 Total Weekly Salary: $420.00 Name: Peter SSN: 222-00-0000 Bonus Rate: 10% Base Salary: $50,000.00 Bonus Amount: $5,000.00 Total Annual Salary: $55,000.00 You must use the provided data on the main method. Please DO NOT CHANGE THE MAIN METHOD All classes, methods, calculations and data elements must be properly documented as discussed in class. Please use the main method for the main class below: public class Asg4YourName { } public static void main(String[] args) { } EmployeeListr = new EmployeeList(); r.add(new Hourly Employee("Jim", "400-00-0000", 15.60, 50)); r.add(new Salaried Employee("Alex", "500-00-0000", 81090, .05)); r.add(new Salaried Employee("Tim", "700-00-0000", 111577, .08)); r.add(new Hourly Employee("Mark", "600-00-0000", 21.75, 60)); r.add(new Hourly Employee("Bill", "100-00-0000", 30.00, 45)); r.add(new SalariedEmployee ("Bob", "200-00-0000", 61090, 02)); r.add(new Salaried Employee("Joe", "300-00-0000", 31690, .10)); r.add(new Hourly Employee("Jane", "700-00-0000", 25.50, 60)); r.add(new HourlyEmployee("Emma", "800-00-0000", 12.50, 30)); System.out.println(r);
Expert Answer:
Answer rating: 100% (QA)
JAVA Code for the provided problem statement import javautil abstract class Employee private String name private String ssn public EmployeeString n St... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Water is an essential resource. For that reason moral considerations exert considerable pressure to assure that everyone has access to at least enough water to survive. Yet it appears that equity and...
-
Rueben acquires a warehouse on September 1, 2016, for $3 million. On March 1, 2020, he sells the warehouse. Determine Rueben's cost recovery for 2016 through 2020:
-
Sonata Manufacturing Corporation decided to expand its operations and open a new facility in Illinois. Rather than constructing a new plant, Sonata negotiated a contract to purchase an existing...
-
How can poor specifications lead to poor quality codeddo aspects of a poorly constructed specification necessarily lead to bad software?
-
The following quality cost report came from the records of Nelson Company. Required a. Explain the strategy that Nelson Company initiated to control its quality costs. b. Indicate whether the...
-
CollegePak Company produced and sold 76,000 backpacks during the year just ended at an average price of $36 per unit. Variable manufacturing costs were $15.00 per unit, and variable marketing costs...
-
Which of the following statements is CORRECT? a. If Apple issues additional shares of common stock through an investment banker, this would be a secondary market transaction. b. Only institutions,...
-
Given your identified target market, the product life cycle, and the competitive landscape shown in your positioning, Identify a minimum of 3 IMC tools in the Promotional Mix (e.g. Personal Selling,...
-
Jack Clark, a full-time student living with his parents, had a summer job as a server at a restaurant. Is he required to file a tax return? if yes, why?
-
Codes of ethics have been criticized for transferring responsibility for ethical behavior from the organization to the individual employee. Do you agree? Do you think a code of ethics is valuable for...
-
What is your holding period return on a combined purchase of a stock for $115 and a put option on that stock with strike price of $110 for a premium of 6 if the stock price at the expiration of the...
-
We are the plaintiff in a large lawsuit and believe that it is extremely likely that we will win. We that that this will have a large positive effect on our stock price. Can we book it? Why or why...
-
Question 1: A source node wants to send some data to a destination node using TCP/IP suite. Consider the following details. Items Logical Addresses: 1. Source Node 2. Destination Node Physical...
-
Parkin Industries, a U.S. company, acquired a wholly-owned subsidiary, located in Italy, at the beginning of the current year, for 200,000. The subsidiary's functional currency is the euro. The...
-
Define DiscountPolicy as an interface instead of the abstract class described in Exercise 10. Exercise 10. Create an abstract class DiscountPolicy. It should have a single abstract method...
-
Write a static method removeDuplicates(ArrayList data) that will remove any duplicates of characters in the object data. Always keep the first copy of a character and remove subsequent ones.
-
Repeat the previous programming project, but read the input data from a file and send the output to another file. If you have covered binary files, use binary files; otherwise, use text files. Read...
-
Prove the relationship in Equation (9.210). CC2=CC = 0, (9.210)
-
Show that the relations in Equations (9.256)-(9.258) are valid. E(z) = [C3+2 (I - 3)]4. (9.256)
-
Propose an alternative and simpler structure to that of Figure 9.46 in Example 9.12. The simplified structure should be based on Equation (9.267). Example 9.12. Show the two-band lapped-transform...
Study smarter with the SolutionInn App