subject

Another Type of Employee of the Firm The files Firm. java, Staff. java, StaffMember. java, Volunteer. java, Employee. java, Executive. java, and Hourly. java are from Listings 7.16 - 7.22 in the text. The program illustrates inheritance and polymorphism. In this exercise you will add one more employee type to the class hierarchy (see Figure 7.8 in the text). The employee will be one that is an hourly employee but also earns a commission on sales. Hence the class, which we'll name Commission, will be derived from the Hourly class.
Write a class named Commission with the following features:
It extends the Hourly class.
It has two instance variables (in addition to those inherited): one is the total sales the employee has made (type double) and the second is the commission rate for the employee (the commission rate will be type double and will represent the percent (in decimal form) commission the employee earns on sales (so .2 would mean the employee earns 20% commission on sales)).
The constructor takes 6 parameters: the first 5 are the same as for Hourly (name, address, phone number, social security number, hourly pay rate) and the 6th is the commission rate for the employee. The constructor should call the constructor of the parent class with the first 5 parameters then use the 6th to set the commission rate.
One additional method is needed: public void addSales (double totalSales) that adds the parameter to the instance variable representing total sales.
The pay method must call the pay method of the parent class to compute the pay for hours worked then add to that the pay from commission on sales. (See the pay method in the Executive class.) The total sales should be set back to 0 (note: you don't need to set the hoursWorked back to 0 -- why not?).
The toString method needs to call the toString method of the parent class then add the total sales to that.
To test your class, update Staff. java as follows:
Increase the size of the array to 8.
Add two commissioned employees to the staffList -- make up your own names, addresses, phone numbers and social security numbers. Have one of the employees earn $6.25 per hour and 20% commission and the other one earn $9.75 per hour and 15% commission.
For the first additional employee you added, put the hours worked at 35 and the total sales $400; for the second, put the hours at 40 and the sales at $950.
Compile and run the program. Make sure it is working properly.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, soccerhannah290
Show that there is a language a ⚆ {0, 1} â— with the following properties: 1. for all x â a, |x| ≤ 5. 2. no dfa with fewer than 9 states recognizes a. hint: you don’t have to define a explicitly; just show that it has to exist. count the number of languages satisfying (1) and the number of dfas satisfying (2), and argue that there aren’t enough dfas to recognize all those languages. to count the number of languages satisfying (1), think about writing down all the strings of length at most 5, and then to define such a language, you have to make a binary decision for each string about whether to include it in the language or not. how many ways are there to make these choices? to count the number of dfas satisfying (2), consider that a dfa behaves identically even if you rename all the states, so you can assume without loss of generality that any dfa with k states has the state set {q1, q2, . . , qk}. now think about how to count how many ways there are to choose the other four parts of the dfa.
Answers: 3
image
Computers and Technology, 22.06.2019 00:50, Cnolteb5663
Is one of the most injurious events that can happen to a person in a crash.
Answers: 1
image
Computers and Technology, 23.06.2019 00:10, makailaaa2
My has been slow anyone else’s ?
Answers: 1
image
Computers and Technology, 23.06.2019 05:20, jaylenmiller437
Which operating system is a version of linux?
Answers: 1
You know the right answer?
Another Type of Employee of the Firm The files Firm. java, Staff. java, StaffMember. java, Voluntee...

Questions in other subjects:

Konu
History, 19.03.2020 18:56