The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 6 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
2.11 Program: Food receipt (Python 3)
Note: When accuracy is essential, floats are not used to represent currency due to rounding and accumulation errors. Python provides several primitives specifically developed to implement financial applications. However, these topics are beyond the scope of this lab.
(1) Prompt the user to input a food item name, price, and quantity. Output an itemized receipt. (Submit for 2 points)
Enter food item name: hot dog
Enter item price: 2
Enter item quantity: 4
RECEIPT
4 hot dog @ $ 2.0 = $ 8.0
Total cost: $ 8.0
(2) Extend the program to prompt the user for a second item. Output an itemized receipt. (Submit for 2 points, so 4 points total)
Enter food item name: hot dog
Enter item price: 2
Enter item quantity: 4
RECEIPT
4 hot dog @ $ 2.0 = $ 8.0
Total cost: $ 8.0
Enter second food item name: ice cream
Enter item price: 2.50
Enter item quantity: 3
RECEIPT
5 hot dog @ $ 2.0 = $ 10.0
4 ice cream @ $ 2.5 = $ 10.0
Total cost: $ 20.0
(3) Extend again to output a third receipt that adds a mandatory 15% gratuity to the total cost. Output the total cost, the cost of gratuity, and the grand total. (Submit for 3 points, so 7 points total)
Enter food item name: hot dog
Enter item price: 2
Enter item quantity: 4
RECEIPT
4 hot dog @ $ 2.0 = $ 8.0
Total cost: $ 8.0
Enter second food item name: ice cream
Enter item price: 2.50
Enter item quantity: 3
RECEIPT
5 hot dog @ $ 2.0 = $ 10.0
4 ice cream @ $ 2.5 = $ 10.0
Total cost: $ 20.0
15% gratuity: $ 3.0
Total with tip: $ 23.0
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly