Python Console Application: Payroll Evaluation - 2 Weeks
Python Console Application: Payroll Evaluation - 2 Weeks
Introduction
Like a regular computer language, Python provides many ways to control and specify how values, especially numbers, should be displayed to the user.
Practical Learning: Creating the Application
print("Payroll Evaluation") print("===========================================================") print("Enter the following pieces of information") print("-----------------------------------------------------------") print("Employee Information") firstName = input("First Name: ") lastName = input("Last Name: ") hSalary = float(input("Hourly Salary: ")) print("===========================================================") print("Time worked - First Week") print("-----------------------------------------------------------") wk1Monday = float(input("Monday: ")) wk1Tuesday = float(input("Tuesday: ")) wk1Wednesday = float(input("Wednesday: ")) wk1Thursday = float(input("Thursday: ")) wk1Friday = float(input("Friday: ")) print("===========================================================") print("Time worked - Second Week") print("-----------------------------------------------------------") wk2Monday = float(input("Monday: ")) wk2Tuesday = float(input("Tuesday: ")) wk2Wednesday = float(input("Wednesday: ")) wk2Thursday = float(input("Thursday: ")) wk2Friday = float(input("Friday: ")) wk1TimeWorked = wk1Monday + wk1Tuesday + wk1Wednesday + wk1Thursday + wk1Friday wk2TimeWorked = wk2Monday + wk2Tuesday + wk2Wednesday + wk2Thursday + wk2Friday wk1RegTime = wk1TimeWorked wk1Overtime = 0.00 wk1RegPay = hSalary * wk1TimeWorked wk1OverPay = 0.00 wk2RegTime = wk2TimeWorked wk2Overtime = 0.00 wk2RegPay = hSalary * wk2TimeWorked wk2OverPay = 0.00 if wk1TimeWorked > 40.00: wk1RegTime = 40.00 wk1Overtime = wk1TimeWorked - 40.00 wk1RegPay = hSalary * 40.00 wk1OverPay = hSalary * 1.50 * wk1Overtime if wk2TimeWorked > 40.00: wk2RegTime = 40.00 wk2Overtime = wk2TimeWorked - 40.00 wk2RegPay = hSalary * 40.00 wk2OverPay = hSalary * 1.50 * wk2Overtime wk1NetPay = wk1RegPay + wk1OverPay wk2NetPay = wk2RegPay + wk2OverPay netPay = wk1NetPay + wk2NetPay print("===========================================================") print("Payroll Evaluation") print("===========================================================") print("Employee Information") print("-----------------------------------------------------------") print(f"Full Name: {firstName} {lastName}") print(f"Hourly Salary: {hSalary:5.2f}") print("===========================================================") print("Time Worked Summary") print('--------+--------+---------+-----------+----------+--------') print(" | Monday | Tuesday | Wednesday | Thursday | Friday") print('--------+--------+---------+-----------+----------+--------') print(f" Week 1 | {wk1Monday:5.2f} |{wk1Tuesday:6.2f} |{wk1Wednesday:8.2f} |{wk1Thursday:7.2f} |{wk1Friday:6.2f}") print('--------+--------+---------+-----------+----------+--------') print(f" Week 2 | {wk2Monday:5.2f} |{wk2Tuesday:6.2f} |{wk2Wednesday:8.2f} |{wk2Thursday:7.2f} |{wk2Friday:6.2f}") print("========+========+=========+===========+==========+========") print("\t\t\t\tPay Summary") print("-----------------------------------------------------------") print("\t\t\t\t\tTime Pay") print("-----------------------------------------------------------") print(f"\tFirst Week\tRegular:\t{wk1RegTime:4.2f}\t{wk1RegPay:8.2f}") print("-----------------------------------------------------------") print(f"\t\t\tOver Time:\t{wk1Overtime:5.2f}\t{wk1OverPay:8.2f}") print(f"-----------------------------------------------------------") print(f"\t\t\tWeekly Pay:\t{wk1NetPay:16.2f}") print("==========================================================") print(f"\tSecond Week\tRegular:\t{wk2RegTime:4.2f}\t{wk2RegPay:8.2f}") print("-----------------------------------------------------------") print(f"\t\t\tOver Time:\t{wk2Overtime:5.2f}\t{wk2OverPay:8.2f}") print("-----------------------------------------------------------") print(f"\t\t\tWeekly Pay:\t{wk2NetPay:16.2f}") print("===========================================================") print(f"\t\t\tNet Pay:{netPay:24.2f}") print("===========================================================")
First Name: Michael Last Name: Carlock Hourly Salary: 28.46 Week 1 Monday: 7 Tuesday: 8 Wednesday: 6.5 Thursday: 8.5 Friday: 7.5 Week 2 Monday: 9.5 Tuesday: 8.5 Wednesday: 10.5 Thursday: 9 Friday: 8Here are are the results:
Payroll Evaluation =========================================================== Enter the following pieces of information ----------------------------------------------------------- Employee Information First Name: Michael Last Name: Carlock Hourly Salary: 28.46 =========================================================== Time worked - First Week ----------------------------------------------------------- Monday: 7 Tuesday: 8 Wednesday: 6.5 Thursday: 8.5 Friday: 7.5 =========================================================== Time worked - Second Week ----------------------------------------------------------- Monday: 9.5 Tuesday: 8.5 Wednesday: 10.5 Thursday: 9 Friday: 8 =========================================================== Payroll Evaluation =========================================================== Employee Information ----------------------------------------------------------- Full Name: Michael Carlock Hourly Salary: 28.46 =========================================================== Time Worked Summary --------+--------+---------+-----------+----------+-------- | Monday | Tuesday | Wednesday | Thursday | Friday --------+--------+---------+-----------+----------+-------- Week 1 | 7.00 | 8.00 | 6.50 | 8.50 | 7.50 --------+--------+---------+-----------+----------+-------- Week 2 | 9.50 | 8.50 | 10.50 | 9.00 | 8.00 ========+========+=========+===========+==========+======== Pay Summary ----------------------------------------------------------- Time Pay ----------------------------------------------------------- First Week Regular: 37.50 1067.25 ----------------------------------------------------------- Over Time: 0.00 0.00 ----------------------------------------------------------- Weekly Pay: 1067.25 ========================================================== Second Week Regular: 40.00 1138.40 ----------------------------------------------------------- Over Time: 5.50 234.79 ----------------------------------------------------------- Weekly Pay: 1373.20 =========================================================== Net Pay: 2440.45 =========================================================== Press any key to continue . . .
|
|||
Home | Copyright © 2021-2025, FunctionX | Sunday 22 December 2024, 14:20 | Home |
|