By using while loop OR do..while loop, write a program that displays a list of groceries. Then, allow user to insert number of product that they want to buy, the item's code and quantity for each item. Finally, display the total price that the user needs to pay. Valid input for the number of product and quantity is positive number. Meanwhile valid number for items' code is only from 1 to 4.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 20PE
icon
Related questions
Question
By using while loop OR do..while loop, write a program that displays a list of groceries. Then, allow user to
insert number of product that they want to buy, the item's code and quantity for each item. Finally, display the
total price that the user needs to pay. Valid input for the number of product and quantity is positive number.
Meanwhile valid number for items' code is only from 1 to 4.
1 Cooking oil
2 Curry powder RM 3.40
3 Detergent
Potato chips
RM 2.50
RM 8.50
4
RM 3.20
Sample output
Emer number of product that you want to purchase (press 0 to exit) : 2
1.Enter item's code that you want to buy : 3
1.Enter the quantity of item that you want to buy: 1
2.Enter item's code that you want to buy : 0
2.Enter the quantity of item that you want to buy: 0
2.Enter item's code that you want to buy : 1
2.Enter the quantity of item that you want to buy; 2
Total price is RM 13.50
Transcribed Image Text:By using while loop OR do..while loop, write a program that displays a list of groceries. Then, allow user to insert number of product that they want to buy, the item's code and quantity for each item. Finally, display the total price that the user needs to pay. Valid input for the number of product and quantity is positive number. Meanwhile valid number for items' code is only from 1 to 4. 1 Cooking oil 2 Curry powder RM 3.40 3 Detergent Potato chips RM 2.50 RM 8.50 4 RM 3.20 Sample output Emer number of product that you want to purchase (press 0 to exit) : 2 1.Enter item's code that you want to buy : 3 1.Enter the quantity of item that you want to buy: 1 2.Enter item's code that you want to buy : 0 2.Enter the quantity of item that you want to buy: 0 2.Enter item's code that you want to buy : 1 2.Enter the quantity of item that you want to buy; 2 Total price is RM 13.50
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning