Question: All done in Java : 1. Create a class Contractor . 2. Create the following instance variables that will be accessible only within this class:

All done in Java :

1. Create a class Contractor.

2. Create the following instance variables that will be accessible only within this class:

String name;

int number;

int startDay,startMonth,startYear;

float Pay;

3. Create a default constructor that will initialize name to Unknown, number to 0, startDay to 1, startMonth to 1, and startYear to 2018.

4. Create an overloaded constructor that will allow you to initialize name, number, startDay, startMonth, and startYear.

5. Create an overloaded constructor that will allow you to initialize name and number, and set startDay to 1, startMonthto 1, and startYear to 2018.

6. Provide both get and set methods for all of the variables.

7. Create a class variable as shown below:

int totalContractors =0;

8. Each time a constructor is called add one to the totalContractors.

9. Add a get method for totalContractors.

10. Create a constant class variable int currentYear and set it to 2018.

11. Create a method named computePay that will calculate the Pay as follows: worked for over 10 years, payrate per hour is 20.50f, worked for over 5 years, payrate per hour is 15.45f, otherwise payrate payrate per hour is 12.90f. Assume that all contractors work 40 hours a week when computing the pay. Return the Pay.

12. Create a method toString that returns a String that displays the name and Pay.

13. Create a driver class UseContractors. This class should be a standalone application with a main method.

14. Instantiate an object named seniorContractor with name Joan, number to 25, startDay to 7, startMonth to 5, and startYear to 2004.

15. Call the computePay method on the seniorContractor object.

16. Call the toString method inside a System.out.println statement.

17. Instantiate an object named juniorContractor with the default constructor.

18. Call setName for this object and pass in Mike. Call setNumber for this object and pass in 125.

19. Call setStartDay for this object and pass 7.

20. Call setStartMonth for this object and pass 2.

21. Call setStartYear for this object and pass 2010.

22. Call getPay on juniorContractor object inside a System.out.println statement.

23. Call getTotalContractors method on the class inside a System.out.println statement.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!