In: Computer Science
Goals: Concepts related to conditional statements in Python. This is a Python program. You DON’T need loops for this.
Below is the programming task.
An employee is paid at a rate of $17.25 per hour for up to 40 regular hours worked in a week. If the employee works more than 40 hours, it is considered overtime. Any hours over 40 hours but less than or equal to 60 are paid at the overtime rate ($12.34 per hour). Any hours over 60 hours but less than equal to 80 hours are paid at the overtime rate ($14.34 per hour). Any hours over 80 hours are paid at the overtime rate ($16.00 per hour).
From the worker’s gross pay, 14% is withheld for federal income tax, 5% is withheld for state income tax. $80 is withheld to cover the insurance of the worker and 2 dependents. If the worker has more than 2 dependents, then an additional $25 is withheld per dependent for insurance. Write a python program that will read in the name of the employee, number of hours worked in a week and the number of dependents as input. The program should then output the worker’s name, number of dependents, gross pay, each withholding amount, and the net take-home pay for the week.
Note that the ONLY INPUTS the user provides are
- The employee’s name.
- The number of hours worked in the week.
- The number of dependents.
Below are four Sample I/O
Net Paycheck Calculator
Employee's Name: John Smith
Number of Hours Worked in a Week: 43
Number of Employee's Dependents: 3
---------------------------------------------------------------------
Employee's name :John Smith
Number of Dependents :3
Hours worked :43
Overtime hours :3
Gross Income :$727.02
State Tax Withheld @ 5% :$36.35
Federal Tax Withheld @ 14% :$101.78
Worker and 2 Dependents' Insurance :$80.00
Additional Dependents' Insurance :$25.00
---------------------------------------------------------------------
Net Take Home Pay :$483.89
Net Paycheck Calculator
Employee's Name: John Smith
Number of Hours Worked in a Week: 63
Number of Employee's Dependents: 0
---------------------------------------------------------------------
Employee's name :John Smith
Number of Dependents :0
Hours worked :63
Overtime hours :23
Gross Income :$979.82
State Tax Withheld @ 5% :$48.99
Federal Tax Withheld @ 14% :$137.17
Worker and 2 Dependents' Insurance :$80.00
Additional Dependents' Insurance :$0.00
---------------------------------------------------------------------
Net Take Home Pay :$713.65
Net Paycheck Calculator
Employee's Name: John Smith
Number of Hours Worked in a Week: 35
Number of Employee's Dependents: 2
---------------------------------------------------------------------
Employee's name :John Smith
Number of Dependents :2
Hours worked :35
Overtime hours :0
Gross Income :$603.75
State Tax Withheld @ 5% :$30.19
Federal Tax Withheld @ 14% :$84.53
Worker and 2 Dependents' Insurance :$80.00
Additional Dependents' Insurance :$0.00
---------------------------------------------------------------------
Net Take Home Pay :$409.04
Net Paycheck Calculator
Employee's Name: John Smith
Number of Hours Worked in a Week: 82
Number of Employee's Dependents: 4
---------------------------------------------------------------------
Employee's name :John Smith
Number of Dependents :4
Hours worked :82
Overtime hours :42
Gross Income :$1255.60
State Tax Withheld @ 5% :$62.78
Federal Tax Withheld @ 14% :$175.78
Worker and 2 Dependents' Insurance :$80.00
Additional Dependents' Insurance :$50.00
---------------------------------------------------------------------
Net Take Home Pay :$887.04
import random
import sys
import os
# Python Program to find Area of a Rectangle using Functions
#taking input
print(" Net Paycheck Calculator ")
name = input("Employee's Name: ")
H_worked = int(input('Number of Hours Worked in a Week:'))
Depen = int(input('Number of Employee\'s Dependents:'))
extra = max(0,Depen-2)
O_hours = H_worked - 40
hours = H_worked;
type1 = 0
type2 = 0
type3 = 0
reg_hour = min(H_worked,40)
hours = hours - min(H_worked,40)
#divided the over time in three types
#type1= 40 to 60
#type2 = 60 to 80
#type3 = 80 to above
if(hours>0):
type1 = min(hours,20)
hours = hours- 20
if(hours>0):
type2 = min(hours,20)
hours = hours- 20
if(hours>0):
type3 = hours
Gross = reg_hour*17.25 + type1*12.34 + type2*14.34 + type3*16
#calculated gross salary
f_tax = Gross * 0.14
s_tax = Gross * .05 #state tax
insurence_fixed = 80 #fixed insurence of 2 dependents
insurence_add = extra*25 #additional insurence of more than 2
dependents
net = Gross- (f_tax + insurence_fixed + insurence_add + s_tax) #calculated net pay
#printed all the things
print(" ---------------------------------------- " )
print(" Employee's name:%s" %name)
print(" Number of Dependents: %d" %Depen)
print(" Hours worked :%d" %H_worked)
print(" Overtime hours :%d" %O_hours)
print(" Gross Income :$%d" %Gross)
print(" State Tax Withheld @5%%:$%.2f" %s_tax)
print(" Federal Tax Withheld @14%%:$%.2f" %f_tax)
print(" Worker and 2 Dependents' Insurance: %.2f"
%insurence_fixed)
print(" Additional Dependents' Insurance: %.2f" %insurence_add)
print(" ---------------------------------------- " )
print(" Net Take Home Pay:$ %.2f" %net)