Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # U07_Ex01_overtime_calc
- #
- # Author: David Hanft
- # Course: Coding for OOP
- # Section: A3
- # Date: 13 Nov 2017
- # IDE: Python 3.6.2
- #
- # Assignment Info
- # Exercise: 1
- # Source: Python Programming
- # Chapter: 7
- #
- # Program Description
- # This program calculates the extra pay (time-and-a-half) for people who worked
- # above 40 hours in a given week.
- #
- # Algorithm (pseudocode)
- # def main():
- # input for number of hours
- # input for hourly rate
- # run calc function
- # def calc():
- # if hours > 40
- # time = hours-40/2+hours
- # total_wage = time * wage
- # else:
- # total_wage = time * wage
- # print total_wage
- def main():
- print('\nThis program calculates your total wage for the week.\n')
- hours = int(input('\nHours worked: '))
- wage = int(input('\nWage: '))
- calc(hours, wage)
- total_wage = calc(hours, wage)
- print('Total Wage:', total_wage)
- def calc(hours, wage):
- # time and a half calculation if the hours worked is over 40
- if hours > 40:
- hours = (hours-40)/2+hours
- total_wage = hours*wage
- else:
- total_wage = hours*wage
- return total_wage
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment