CS303E Homework 3

Instructor: Dr. Bill Young
Due Date: Friday, September 17, 2021 at 11:59pm


Note that this is problem 3.9 (pp. 87-88) from the book.

Write a program that reads in the following information and prints a payroll statement:

  1. Employee's name (e.g., Smith)
  2. Number of hours worked in a week (e.g., 10)
  3. Hourly pay rate (e.g., 9.75)
  4. Federal tax withholding rate (e.g., 20%)
  5. State tax withholding rate (e.g., 9%)
All of the numbers entered should be treated as floating point numbers. Percentages should be input as decimals, but displayed as percentages in the payroll statement. You do not have to validate inputs.

Print your money amounts with a dollar sign and two decimal places after the decimal point. Non-money amounts should print with one decimal place after the decimal point. Print a blank line before the input lines and output lines, as shown in the example below.

A sample run is shown below. This run is from the command line; yours can run under IDLE or another IDE. However, the TA should be able to run your program file at the command level. Your output should be exactly like this for these input data. There is a single space after each colon.

> python3 Payroll.py

Enter employee's name: Smith
Enter number of hours worked in a week: 10
Enter hourly pay rate: 9.75
Enter federal tax withholding rate: 0.20
Enter state tax withholding rate: 0.09

Employee Name: Smith
Hours Worked: 10.0
Pay Rate: $9.75
Gross Pay: $97.50
  Federal Withholding (20.0%): $19.50
  State Withholding (9.0%): $8.78
  Total Deduction: $28.27
Net Pay: $69.22
Note that the state withholding amount listed in the book differs by 1 cent. This is probably due to a rounding difference in the two versions. Either is fine. Note also that the book version does not display two digits after the decimal point in all cases of monetary amounts; your program should, even if the trailing digit is a zero.

Turning in the Assignment:

The program should be in a file named Payroll.py. Submit the file via Canvas before the deadline shown at the top of this page. Submit it to the assignment weekly-hw3 under the assignments sections by uploading your python file.

Your file must compile and run before submission. It must also contain a header with the following format:

# File: Payroll.py
# Student: 
# Course Name: CS303E
# Date Created:
# Date Last Modified: 
# Description of Program: 

If you submit multiple times to Canvas, it will rename your file name to something like Payroll-1.py, Payroll-2.py, etc. Don't worry about that; we'll grade the latest version.