Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 And Expert Systems Applications 24th International Conference Dexa 2013 Prague Czech Republic August 2013 Proceedings Part 2 Lncs 8056

Authors: Hendrik Decker ,Lenka Lhotska ,Sebastian Link ,Josef Basl ,A Min Tjoa

2013th Edition

3642401724, 978-3642401725

More Books

Students also viewed these Databases questions

Question

7. Identify six intercultural communication dialectics.

Answered: 1 week ago