Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language Ice Cream Program Assignment Write a program that uses a function to ask the user to choose an ice cream flavor from a

C language Ice Cream Program Assignment

Write a program that uses a function to ask the user to choose an ice cream flavor from a menu (see output below.) You do NOT have to validate this users input for the flavor of ice cream.

Your main() function will then ask for the number of scoops. You must validate this data! Make sure that the user chooses at least 1 scoop but no more than 4. If they try another other, you must give them an error message and allow them to try again.

Your program will then calculate and display the cost of the ice cream. The cost of ice cream is $ .75 for the cone and $1.25 per scoop.

Your program will continue asking customers for the flavor and number of scoops until they choose Q to quit.

The program will then send all of the data to a function to display the total number of cones sold, the total amount collected, and the total scoops of each type of ice cream sold.

Sample Output:

Please Choose your Favorite Flavor!

V - Vanilla

C - Chocolate

S - Strawberry

Q - Quit

-----> v

How many scoops would you like? 2

Your ice cream cone cost $ 3.25

Please Choose your Favorite Flavor!

V - Vanilla

C - Chocolate

S - Strawberry

Q - Quit

-----> c

How many scoops would you like? 5

That is an invalid number of scoops!

You may only choose between 1 and 4

Please try again!

How many scoops would you like? 0

That is an invalid number of scoops!

You may only choose between 1 and 4

Please try again!

How many scoops would you like? 3

Your ice cream cone cost $ 4.50

Please Choose your Favorite Flavor!

V - Vanilla

C - Chocolate

S - Strawberry

Q - Quit

-----> s

How many scoops would you like? 1

Your ice cream cone cost $ 2.00

Please Choose your Favorite Flavor!

V - Vanilla

C - Chocolate

S - Strawberry

Q - Quit

-----> q

The total number of cones sold: 3

The total scoops of vanilla sold: 2

The total scoops of chocolate sold: 3

The total scoops of strawberry sold: 1

The total amount collected: $ 9.75

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_2

Step: 3

blur-text-image_3

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

Mobile Usability

Authors: Jakob Nielsen, Raluca Budiu

1st Edition

0133122131, 9780133122138

More Books

Students also viewed these Programming questions

Question

Prove that if Σ an is absolutely convergent, then a. an

Answered: 1 week ago