In: Computer Science
To include variables in the input prompt, you must use concatenation character (+). For example: assume you already asked for input of employee's first name and last name (they are stored into variables FirstName and LastName, then use this prompt to ask for employee's weekly hours which includes the employee's full name in the input statement.
Hours = float(input("Enter " + FirstName + ' ' + LastName + '\'s Weekly Hours: '))
The company which uses this program has TWO employees.
Write a Python application that will allow the user (payroll clerk) to enter payroll data for two hourly employees. Input Data includes:
Repeat the above prompt for two employees
Must use if statements to check if the employee requires an overtime pay.
Up to 40 hours on employee’s hourly rate; any hours over 40 must be pay at a time and a half (1.5 of rate). Using , and 2 decimal places for all currency in the output
Display the followings for each employee:
Then finally output payroll info for the entire company (total amount for both employees)
Sample input/output (user input is in bold italic)
Enter Employee’s ID (i.e. AF101): AS111
Enter Employee’s Last Name: Wong
Enter Employee’s First Name: Wanda
Enter Wanda Wong’s Weekly Hours: 36.5
Enter Wanda Wong’s Hourly pay rate per hour: 50
Enter Wanda Wong’s Income tax rate: 0.25
Enter Employee’s ID (i.e. AF101): AS256
Enter Employee’s Last Name: Johnson
Enter Employee’s First Name: Betty
Enter Betty Johnson’s Weekly Hours: 52
Enter Betty Johnson’s Hourly pay rate per hour: 30
Enter Betty Johnson’s Income tax rate: 0.20
Weekly Pay stub for AS111 Wanda Wong
36.5 Hours Worked @ $50.00
Gross pay of $1,825.00
Less Taxes Withheld @ 25.0% $456.25
Net Pay $1,368.75
Weekly Pay stub for AS256 Betty Johnson
52 Hours Worked @ $30.00
Gross pay of $1,740.00
Less Taxes Withheld @ 20.0% $348.00
Net Pay $1,392.00
Total Company payroll expense for the week: $3,565.00
Total Cash payments to Employees: $2,760.75
def calculation(hours,rate,taxrate):
list=[]
if(hours>40):
extrahours=hours-40
hours=hours-extrahours
extrapay=extrahours*(rate*1.5)
grosspay=(hours*rate)+extrapay
tax=grosspay*taxrate
netpay=grosspay-tax
list.append(grosspay)
list.append(tax)
list.append(netpay)
else:
grosspay=hours*rate
tax=grosspay*taxrate
netpay=grosspay-tax
list.append(grosspay)
list.append(tax)
list.append(netpay)
return list
def employeedetails():
details=[]
id=input("Enter Employee's ID(i.eAF101):")
lname=input("Enter Employee's Last Name:")
fname=input("Enter Employee's First Name:")
hours=float(input("Enter "+fname+' '+lname+'\'s Weekly Hours:'))
rate=float(input("Enter "+fname+' '+lname+'\'s Hourly pay rate per hour:'))
taxrate=float(input("Enter "+fname+' '+lname+'\'s Income tax rate:'))
details.append(id)
details.append(lname)
details.append(fname)
details.append(hours)
details.append(rate)
details.append(taxrate)
return details
def printmethod(id,fname,lname,hours,rate,grosspay,taxrate,tax,netpay):
print("Weekly Pay stub for "+id)
print(fname+' '+lname)
print(str(hours)+' Hours Worked @ ${:,.2f}'.format(rate))
print('Gross pay of ${:,.2f}'.format(grosspay))
print('Less Taxes Withheld @ '+str(taxrate*100)+'%')
print('${:,.2f}'.format(tax))
print('Net Pay ${:,.2f}'.format(netpay))
emp1details=employeedetails();
emp2details=employeedetails();
emp1=calculation(emp1details[3],emp1details[4],emp1details[5])
emp2=calculation(emp2details[3],emp2details[4],emp2details[5])
printmethod(emp1details[0],emp1details[2],emp1details[1],emp1details[3],emp1details[4],emp1[0],emp1details[5],emp1[1],emp1[2])
printmethod(emp2details[0],emp2details[2],emp2details[1],emp2details[3],emp2details[4],emp2[0],emp2details[5],emp2[1],emp2[2])
print('Total Company payroll expense for the week: ${:,.2f}'.format(emp1[0]+emp2[0]))
print('Total Cash Payment to Employees: ${:,.2f}'.format(emp1[2]+emp2[2]))
below are the code pics in the ide for reference like indentation
Below is the Screen shot of output of the program