Site icon Doc Sity

GC Week 5 Computer Science Number Guessing Game Project

GC Week 5 Computer Science Number Guessing Game Project

Description

Programs to upload: p27.cpp, p28.cpp, p29.cpp, p30.cpp, p31.cpp, p32.cpp, p33.cpp

Once each program is working, copy/paste the program test run (output) at the bottom of your code as a multiline comment, as shown in the p1 program! 

Program 27:

Write a number guessing game. The computer will generate a random number between 0 and 100.

The user will be prompted to guess the number.

If the number guessed is greater than the random number, an appropriate message will appear, with a similar message for low guesses.

The user should keep guessing until the correct number is guessed.

An appropriate message should congratulate the user for guessing the correct number.

Sample Run:

(to cheat, show the random number) 78

Please enter a guess b/w 0 – 100: 56

No, it’s higher than that.

Please enter a guess b/w 0 – 100: 85

No, it’s lower than that.

Please enter a guess b/w 0 – 100:78 

Correct, you got it…It took your 3 guesses!

Save and submit it as p27.cpp

Program 28:

Write a program that generates X random integers Num.

Num is a random number between 20 to 50. 

X is a random number between 10 to 15.

Calculate and show the Smallest, Largest, Sum, and Average of those numbers.

HINTs to find Smallest

1) X is a random number between 10 to 15… for example 11

2) Make the first random number Num of 20 to 50 before the loop.

3) Before the loop, Smallest equals Num above 

4) Use a loop to make the rest (X – 1) of the random numbers Num,

5) if the Num generated in the above loop is less than Smallest, then Smallest equals that number

HINTS TO FIND SMALLEST

1) X is a random number between 10 to 15… for example 11

2) Make the first random number Num of 20 to 50 before the loop.

3) Before the loop, Smallest equals Num above

4) Use a loop to make the rest (X – 1) of the random numbers Num,

5) if the Num generated in the above loop is less than Smallest, then Smallest equals that number 

PROGRAM 29:

Write a program to compute a gymnastics competition score.

There are 4 judges who mark the gymnasts in the range of 0 to 10, and the overall score is the average of the marks.

An error message should appear if a mark is entered that is out of the range (0-10) and then ask the user to input a valid mark again.

Output the average.

Format the output nicely, so it is easy to read and to follow. 

PROGRAM 30:

Write a program to let a child practice arithmetic skills.

The program should first ask for what kind of practice is wanted: +, -, * (no division).

Two random numbers will be generated (0 – 9).

If the child answers incorrectly, the problem should be repeated (same numbers used) until they get it right.

If the child answers the question correctly, a message should appear to congratulate them.

At the end of the program, it should ask the child if they want to try again, which will let the user repeat the program as many times as desired. 

PROGRAM 31:

You have the choice of:

1) 1 million $

2) 1 penny which doubles its value during the next 30 days

Which one would you chose?

Write a program to compute and show the value of the penny at day 30, and exactly how much more (or less) that is compared to the 1 million dollars.

Save and submit it as p31.cpp

Program 32:

Write a Dice Game program that would result in output as shown below. 

PROGRAM 33:

Write a program which asks the user to type in the length of three sides of a triangle: a, b, c

1) Let the user know that the shape is a RIGHT TRIANGLE if either one is true:

  • a2 is equal to b2 + c2
  • b2 is equal to a2 + c2
  • c2 is equal to a2 + b2

2) Let the user know that it is an EQUILATERAL TRIANGLE if BOTH of the conditions are true:

    • a is equal to b
    •  b is equal to c

Explanation & Answer:
1 Project
User generated content is uploaded by users for the purposes of learning and should be used following our honor code & terms of service.

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Exit mobile version