006-004-007

Do-While Loop: Menu Choice

Easy

Problem Description

Do-while loop: Menu Choice

In this problem, you will create a program that uses a do-while loop to repeatedly display a menu until a valid choice (1-3) is entered, showing "Invalid choice" for invalid inputs and "Selected: [choice]" for valid inputs, and displays the result to standard output.

Learning Objective: Learn processing executed at least once with do-while loop

Create program that repeatedly displays menu until valid choice (1, 2, 3) is selected. Use do-while loop to display menu at least once.

Input

Multiple lines: Choices (integer, 1-3 correct, last is correct)

Output

Menu choice (1-3): [input1]
Invalid choice
Menu choice (1-3): [input2]
Selected: [input2]

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up