Question: Lab 2.1.6 Write a program that uses a while loop statement to perform the following task: You are going to write a guessing game program.

Lab 2.1.6 Write a program that uses a while loop statement to perform the following task:

You are going to write a guessing game program. The program will ask the user to guess a number between 1 and 10. The input will be compared to the secret number, which is 5. If the user guessed the wrong number the program will output sorry, guess again and ask the user to enter another number. If the user guesses correctly then the program will output thats correct! and stop.

Lab 2.1.7 Write a program that uses a FOR statement to perform the following task:

The program will ask the user to input a number. The number will be stored as the variable NUMBER. You will then compose a loop using the while statement to display C++ is great!. The statement will perform the printout a number of times equal to the number stored in NUMBER.

Example: the user enters the number 3 The output should be:

C++ is great! C++ is great! C++ is great!

Lab 2.1.8 Create a switch that will print out the following choices: Choose from the following menu:

1. Hamburger 2. Fries 3. Coke 4. Exit

The default choice will print out thats not a valid entry This is what will be printed out when the user makes their choice:

Hamburger

$2.50

Fries

$1.24

Coke

$1.29

Exit

Thanks for shopping at McDaves

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!