급여 계산기
# pay_calc.py
# This program takes input of hours worked and hourly rate and calculates
# the total wages for the week.
# by: Scott Gordon
def main():
print("***** Welcome to the Pay Calculator *****\n")
hours_worked = float(input("Enter the amount of hours worked: "))
hourly_rate = float(input("Enter the hourly rate: "))
def pay_calculator(hours, pay_rate):
"""Calculates total pay based on the amount of hours worked and pay
rate. Time-and-a-half is calculated for any hours worked over 40."""
if (hours > 0) and (pay_rate > 0):
if hours <= 40:
pay = hours * pay_rate
return f"\nYour pay is ${pay:.2f}"
else:
pay = (40 * pay_rate) + ((pay_rate * 1.5) * (hours - 40))
return f"\nYour pay with overtime is ${pay:.2f}"
else:
return "\nYou must enter a number greater than 0 for hours and pay."
print(pay_calculator(hours_worked, hourly_rate))
if __name__ == '__main__':
main()
Sharon McCutcheon에 Unsplash의 사진
Reference
이 문제에 관하여(급여 계산기), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/sagordondev/pay-calculator-1ddo텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)