Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. #####################################
  2. # #
  3. # Tip Caluclator Mk. II #
  4. # Nicholas Savory #
  5. # #
  6. #####################################
  7.  
  8. # Tip amount variables (15%, 18%, 20%)
  9. tip_15 = 0.15
  10. tip_18 = 0.18
  11. tip_20 = 0.20
  12.  
  13. # Introductions
  14. print("Welcome to the Tip Calculator by Nicholas Savory!\n")
  15.  
  16. # Prompt for tip amount
  17. bill = input("What was the cost of your meal? $")
  18. meal = float(bill.strip('$'))
  19.  
  20. # Quit if program hits exception (meal <= 0)
  21. if meal <= 0:
  22. print("You must enter an amount over zero(0)! Please try again.")
  23. quit()
  24.  
  25. else:
  26. tip = int(input("Which tip percentage would you like to give today? 15% (1), 18% (2), or 20%(3)? "))
  27.  
  28. # Tip calculations + output
  29. if tip == 1:
  30. tip_amount = meal * tip_15
  31. total = meal + meal * tip_15
  32. print("You tipped $%.2f for a total cost of $%.2f.\n" % (tip_amount, total))
  33.  
  34. elif tip == 2:
  35. tip_amount = meal * tip_18
  36. total = meal + meal * tip_18
  37. print("You tipped $%.2f for a total cost of $%.2f.\n" % (tip_amount, total))
  38.  
  39. elif tip == 3:
  40. tip_amount = meal* tip_20
  41. total = meal + meal * tip_20
  42. print("You tipped $%.2f for a total cost of $%.2f.\n" % (tip_amount, total))
  43.  
  44. else:
  45. print("You didn't pick a correct value. Please try again.")
  46.  
  47. # Closing statement if tip is processed. Quit otherwise.
  48. if tip <= 3:
  49. print("Thank you for your business! This calculator was made by Nicholas Savory on 1/06/2017!")
  50.  
  51. else:
  52. quit()
  53.  
  54. # Survey time!
  55. score = int(input("How would you rate it on a scale of 1-10? "))
  56.  
  57. # Response based on rating
  58. if score >= 8:
  59. print("Happy to see you enjoyed it!")
  60.  
  61. elif score >= 6:
  62. print("We will improve it!")
  63.  
  64. else:
  65. print("I'm sorry for your bad experience!")
  66.  
  67. # Store the latest rating
  68. with open("Rating.txt", "a") as text_file:
  69. print("Rating: {}".format(score), file=text_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement