Question: Write a program in C that prompts a user to select any five beverages of your choice (e.g Coke, Lemon Tea, etc.). User should be

Write a program in C that prompts a user to select any five beverages of your choice (e.g Coke, Lemon

Tea, etc.). User should be able to select one of these options using only integers from 0 to 4 as inputs.

Once a user has made the choice, print the chosen drink along with its calorie information. You may look

up the calorie information online.

Example input: 3

Example output:

Selected drink: Coca Cola

Calorie count: 140 Calories

Notes:

You can assume that the user will input integers. You do not need to handle invalid inputs of other

types (such as strings, floats, etc.).

Your program should gracefully terminate if a user enters wrong input three times. In addition, after

every invalid attempt, your program should tell the user how many tries he/she has remaining. For

example, the prompt should work something like this:

o Prompt 1: User enters 6. Your program should tell that input is invalid and enter again. Also print

the remaining tries (2).

o Prompt 2: User enters -1. Your program should tell that input is invalid and enter again. Also print

the remaining tries (1).

o Prompt 3: User enters 200. Your program should tell that input is invalid and terminate. Also print

the remaining tries (0).

o If the user enters a correct input on or before the last try, the program should behave normally,

and output should be like the provided example.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!