Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program, using the provided code Lab 4 Program.cpp in Canvas, that calculates the customers grocery bill. It should display a list of items

Write a program, using the provided code Lab 4 Program.cpp in Canvas, that calculates the customers grocery bill. It should display a list of items (veggies, fruits and chips) and asks the customer to select an item. The program should then display a list of available vegetables or fruits of chips and the price for each of them. The customer selects an item and enters the quantity. The program computes and displays the total price. The following is the list of items: V: Veggies F: Fruits C: Chips The following is the list of available veggies: O: Onions ($0.79 per lb) T: Tomatoes ($0.68 per lb) P: Potatoes ($0.82 per lb) The following is the list of available fruits: G: Grapes ($1.9 per lb) A: Apples ($0.98 per lb) B: Bananas ($0.60 per lb) The following is the list of available chips: W: Wavy ($2.28) L: Lays ($2.50) R: Onion Rings ($1.50) Use a switch statement to evaluate the total cost of the customers grocery bill based on the selected item. If invalid input is given, display an error message and terminate the program. Do not use more than one return statement in your program. Sample Run 1: Welcome to the Grocery Store! Enter the item you wish to purchase: V: Veggies F: Fruits C: Chips V Select the vegetable you want to buy: O: Onions ($0.79 per lb) T: Tomatoes ($0.68 per lb) P: Potatoes ($0.82 per lb) T Enter the weight (lb): 5 The total price is $3.4 Sample Run 2: Welcome to the Grocery Store! Enter the item you wish to purchase: V: Veggies F: Fruits C: Chips c Select the chips you want to buy: W: Wavy ($2.28) L: Lays ($2.50) R: Onion Rings ($1.50) l Enter the quantity: 2 The total price is $5

Sample Run 3: Welcome to the Grocery Store! Enter the item you wish to purchase: V: Veggies F: Fruits C: Chips d Invalid choice. Terminating the program. Sample Run 4: Welcome to the Grocery Store! Enter the item you wish to purchase: V: Veggies F: Fruits C: Chips F Select the fruits you want to buy: G: Grapes ($1.9 per lb) A: Apples ($0.98 per lb) B: Bananas ($0.60 per lb) e Invalid choice. Terminating the program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

DESCRIBE the five basic elements of compensation for managers.

Answered: 1 week ago