Final answer:
To create a program with a class for Employees that calculates gross and net weekly pay, follow these steps: create a class, define the constructor, create a method for calculating gross pay, set a class variable for income tax rate, create a method for calculating net pay, and use the class in the main module.
Step-by-step explanation:
In order to create a program with a class for Employees that can calculate gross and net weekly pay, you can follow these steps:
- Create a class called Employee with a constructor that takes a first name, last name, and hourly pay rate.
- Create a method in the class that takes a number of hours and returns the weekly gross pay. Assume that hours in excess of 40 are paid at time and a half (1.5 x the hourly rate).
- Create a class variable that holds the income tax rate percentage and initialize it to 10. Use class methods to get and set that rate.
- Create a method in the class that takes a number of hours and returns the weekly net pay, which is equal to the weekly gross pay minus the income tax.
- In the main module, ask the user for a first name, last name, and hourly rate, and instantiate an instance of the Employee class with that data.
- Ask for the number of hours worked during the week and call the class methods for gross pay and net pay, and display those amounts.