Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions