Question: Write a program to generate a random number between 1 100 and keep it as a secret number. The program will then check if a

Write a program to generate a random number between 1 100 and keep it as a secret number. The program will then check if a user can guess the secret number. The user can continue guessing the number until the number is found or the user can enter 0, which will terminate the program.

Each time the user makes a guess, the program will report as below:

1. Way Too High or Way Too Low (more than 30 off)

2. High or Low (between 10 and 30 points off)

3. A Little High or A Little Low (less than 10 points off)

If secret number is 74 and the user enters 26, the program will print "Way too Low". If the user then says 65, then the program will print "A Little Low". Name this program SecretNumber.cpp

NOTE: The 10 program standards are given below:

1. Program Header . In addition to you name and project number, include a brief description of the program functionality in the header comment for the program

2. Variables and Constants. All variables and constants in a program must be declared at the beginning of the program

3. Initialization. Variables may not be initialized in their declaration.

4. Printing of if-then. Use one of the following

if (expression) statement

if (expression)

Single-statement

if (expression) {

Multiple-statements

}

5. Printing of if-then-else. Use one of the following

if (expression) statement

else statement

if (expression)

Single-statement

else

Single-statement

if (expression) {

Multiple-statements

} else {

Multiple-statements

}

6. Printing of while loops. Use one of the following

while (expression) statement

while (expression)

Single-statement

while (expression) {

Multiple-statements

}

For loops. The bodies of all for-loops must be indented at least 3 (but no more than 5) spaces:

for(int i = 0; i < n; i++) {

cout << "Enter the number:" << flush;

cin >> num;

if (num < 0) num_neg++;

else if (num > 0) num_pos++;

else num_zero++;

}

Methods. The bodies of all functions must be indented at least 3 (but no more than 5) spaces:

double CircleArea(double r) {

const double Pi = 3.1415;

return Pi * r * r;

}

Variable names. Variables that denote things should have names that are nouns or noun phrases.

Method names. Methods that have side effects should have names that are verbs or verb phrases. Methods that return a value should have names that are nouns or noun phrases.

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!