Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

3.46 Rating (162 Votes )

There are 3 Steps involved in it

Step: 1

UseContractorsjava package comaccounts public class UseContractors public static void mainString args Contractor seniorContractor new ContractorJoan 2... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practicing Statistics Guided Investigations For The Second Course

Authors: Shonda Kuiper, Jeff Sklar

1st Edition

321586018, 978-0321586018

More Books

Students also viewed these Programming questions

Question

8 2m 1$ Bm

Answered: 1 week ago