In: Computer Science
Assignment Description
This assignment focuses on programming basics; expressions, variables, constants, methods, selection and loops.
Danny runs an ice cream shop in the inner suburbs of Melbourne. Due to the growing number of customers, Danny has decided to take on extra casual employees. In order to manage payroll for his employees, Danny has decided to develop an employee payroll management system. Details of each employee to be maintained in the system will include; employee id, name, gender (M or F), phone number, hours worked, pay per hour, gross pay, net pay, and income tax payable.
The gross pay is calculated as the number of hours worked multiplied by pay per hour, while the net pay is calculated as the difference between gross pay and income tax payable of which income tax payable is calculated by multiplying gross pay by an income tax rate of 30%. Any hours over forty (40) is paid as an overtime hour at the rate of (2.5) times the base hourly rate.
For example, an employee who has worked a total of 45 hours with an hourly rate of $20 will have;
Regular pay=40*$20=$800
Overtime pay=5 * $20 * 2.5 = $250
Gross pay=$800 + $250 = $1,050
Income tax payable=$1050 * 30%=$315
Net pay=$1050-$315=$735
Task Requirements
Imagine you have been hired to develop this system. Familiarise yourself with the problem description and write a python program named payroll.py with the following functions:
These functions needs to be invoked in correct order within your driver function main (), so that when your program executes, it should be able to produce an output as an employee’s pay slip like the example below.
Submission requirements:
Marking criteria:
Program Demonstration: Students must demonstrate their program in week8 (lab time) to the tutor, and are expected to explain their implementation. Marks will be deducted (50% -maximum) for failing to do demonstration or poor explanation.
Description of criteria |
Marks |
Assignment report |
|
Overview |
0.5 |
Pseudocode |
1 |
Statement of completion and acknowledgement |
1 |
Python implementation |
|
Comments describing the program, methods, author and date |
1.5 |
Design of main function is correctly implemented |
4 |
Design of overtime function is correctly implemented |
2 |
Design gross pay function is correctly implemented |
2 |
Design of income tax payable function is correctly implemented |
2 |
Design of net pay function is correctly implemented |
2 |
Program runs and prints the correct output |
4 |
Total |
20 |
Thanks for the question. Here is the completed code for this problem. Comments are included so that you understand whats going on. Let me know if you have any doubts or if you need anything to change. Thank You !! ============================================================================================= #Function to calculate the overtime hours def calculate_overtime(hrs): if hrs <=40: return 0 else: return hrs-40 #Function to calculate the gross pay def calculate_grosspay(hrs,rate): overtime=calculate_overtime(hrs) return (hrs-overtime)*rate + overtime*rate*2.5 #Function to calculate the income tax payable def calculate_incometax(grosspay): return grosspay*0.30 #Function to calculate the net pay def calculate_netpay(hrs,rate): gross_pay=calculate_grosspay(hrs,rate) i_tax=calculate_incometax(gross_pay) return gross_pay-i_tax # get employee details def input_employee(): name= input('Enter employee name: ') employee_id=input('Enter employee id: ') gender =input('Enter gender (M or F): ') phone_number=input('Enter phone number: ') hours_worked = int(input('Enter hours worked: ')) pay_per_hour=float(input('Enter pay per hour: $')) return name,employee_id,gender,phone_number,hours_worked,pay_per_hour # print details of employee def display(record): print('Employee Name : {}'.format(record[0])) print('Employee ID : {}'.format(record[1])) print('Gender : {}'.format(record[2])) print('Phone Number : {}'.format(record[3])) print('Hours Worked : {}'.format(record[4])) print('Pay Per Hour : {}'.format(record[5])) print('Gross Pay : ${0:.2f}'.format(record[6])) print('Income Tax : ${0:.2f}'.format(record[8])) print('Net Pay : ${0:.2f}'.format(record[7])) # main() def main(): print('Dannys Payroll Management System') records=[] while True: name, id, gender, ph_num, hrs, rate=input_employee() gross_pay=calculate_grosspay(hrs,rate) net_pay=calculate_netpay(hrs,rate) income_tax= calculate_incometax(gross_pay) record=[name, id, gender, ph_num, hrs, rate,gross_pay,net_pay,income_tax] records.append(record) display(record) print('Record saved successfully') add_another=input('Do you want to add another (Y or N): ') if add_another=='n' or add_another=='N': break print('Thanks for using the Payroll Management System. Bye.') main() =================================================================================================