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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started