-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweekly_pay.py
More file actions
41 lines (35 loc) · 1.45 KB
/
weekly_pay.py
File metadata and controls
41 lines (35 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# ***************************************************************
# Name : ProgramNameTong
# Author: Than Tong
# Created : * Course: CIS189
# Version: 1.0
# OS: Windows 11
# IDE: Python
# Copyright : This is my own original work
# based onspecifications issued by our instructor
# Description :
# Input: ADD HERE XXX
# Ouput: ADD HERE XXX
# Academic Honesty: I attest that this is my original work.
# I have not used unauthorized source code, either modified or
# unmodified. I have not given other fellow student(s) access
# to my program.
def hourly_employee_input():
try:
name = input("Enter the employee's name: ")
hours_worked = float(input("Enter the hours worked: "))
hourly_rate = float(input("Enter the hourly pay rate: "))
if hours_worked <= 0 or hourly_rate < 0:
raise ValueError("Hours worked must be greater than 0, and hourly rate cannot be negative.")
total_pay = weekly_pay(hours_worked, hourly_rate)
return f"{name} made ${total_pay:.2f} after working {hours_worked} hours at a rate of ${hourly_rate:.2f}"
except ValueError as e:
return f"Error: {e}. Please enter valid input."
def weekly_pay(hours_worked, hourly_rate):
"""
Calculate the weekly pay based on hours worked and hourly pay rate.
"""
return hours_worked * hourly_rate
if __name__ == "__main__":
result = hourly_employee_input()
print(result)