Advertisement
daringdan100

Untitled

Dec 7th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. def main():
  2. receipt = []
  3.  
  4.  
  5. products = {
  6. "Fries": 2,
  7. "Bacon": 3,
  8. "Hashbrowns": 3,
  9. "Water": 1,
  10. "Sprire": 2,
  11. "Cola": 2,
  12. "Burger": 4,
  13. "Hotdog": 3,
  14. "Salad": 4,
  15. }
  16.  
  17. for key, value in products.items():
  18. print("Item: {:<12}\tPrice: ${:>5.2f}".format(key, value))
  19. accumulator += value
  20.  
  21. print("")
  22. print("Grand total for all is " + value)
  23.  
  24. idx = 0
  25.  
  26. # using a while loop
  27. while idx < len(products):
  28. print(" Meal #" + str(idx) + " " + str(products[idx]))
  29. # incrememt idx by 1
  30. idx += 1
  31.  
  32. print(idx)
  33.  
  34.  
  35.  
  36. print("What would you like to order? (Type 'Done' once finished)")
  37.  
  38. total = 0 #Variable for the total
  39.  
  40. while (True): #Loop for user input for items
  41.  
  42. order = input("Enter Item: ")
  43.  
  44. if (order.lower() == "done"): #breaks the loop by typing done, even if uppercase
  45. break
  46. elif (
  47. order not in str((idx))): #Makes sure items are in the menu if not brings them back with invalid order
  48. print("Invalid Order")
  49. continue
  50. else:
  51. amount = (int)(input("How many: ")) #Allows the user to select how much of an item they desire
  52. total += products[order] * amount #Adds price to total, also uses the amount var
  53. receipt.append((str)(amount) + " orders of meal of order #" + (order) + " Current Total is " + str(total) + "$")
  54. print("")
  55. print("$" + (str)(total))
  56. #Parts of loop above taken from Reddit post, sections mostly changed around other than basics
  57.  
  58.  
  59. print("Total: ${}".format(total)) #Prints the total for user
  60.  
  61. print(receipt)
  62.  
  63.  
  64. print()
  65. print("Complete")
  66. print("")
  67. print('Added the subscripts to the print line in our for loop.')
  68.  
  69. if __name__ == "main":
  70. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement