Guest User

Untitled

a guest
Jul 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #This is a simple program that utilizes variables, functions, & a loop.
  2.  
  3. #Define payroll function
  4. def payroll():
  5. #Payroll calculations
  6. hours = float(input("Enter number of hours: "))
  7. rate = float(input("Enter hourly rate: "))
  8. amount = hours * rate
  9. #Print values
  10. print ("Hours worked:", hours)
  11. print ("Rate:", rate)
  12. print ("Pay amount:", amount)
  13.  
  14. #Define mileage function
  15. def mileage():
  16. #MPG calculations
  17. miles = float(input("Enter number of miles: "))
  18. gas = float(input("Enter gallons of gas: "))
  19. mpg = miles / gas
  20. #Print values
  21. print ("Miles:", miles)
  22. print ("Gas:", gas)
  23. print ("MPG:", mpg)
  24.  
  25. #Define variable
  26. menuSelection = 0
  27.  
  28. #Decision loop
  29. while menuSelection != 3:
  30. # Display options to the user and record their input
  31. print("Press 1 for Payroll Calculation")
  32. print("Press 2 for Mileage Calculation")
  33. print("Press 3 to Exit")
  34. menuSelection = int(input())
  35. #if-else statement
  36. if menuSelection == 1:
  37. payroll()
  38. elif menuSelection == 2:
  39. mileage()
Advertisement
Add Comment
Please, Sign In to add comment