97.7k views
0 votes
On the surface this program seems simple. Allow the player to keep guessing until he/she finds the secret number. But stop and think for a moment. You need a loop to keep running until the player gets the right answer.

Some things to think about as you write your loop:

The loop will only run if the comparison is true.
(e.g., 1 < 0 would not run as it is false but 5 != 10 would run as it is true)
What variables will you need to compare?
What comparison operator will you need to use?
.
Using comments, type a heading that includes your name, Hailey, today’s date, and a short description.

Part 3: Post Mortem Review (PMR)
Using complete sentences, respond to all the questions in the PMR chart.

Review Question Response
What was the purpose of your program?
How could your program be useful in the real world?
What is a problem you ran into, and how did you fix it?
Describe one thing you would do differently the next time you write a program.

User Stacca
by
6.2k points

1 Answer

4 votes

Answer:

You would need a while (true) loop, aka a loop that always runs, OUTSIDE this loop, you would need to generate a random number. Inside the loop, you need to wait for user input and then compare it against the answer variable you generated outside the loop. Then, if the answer is not right, you would need to tell them that and go back to the beginning of the loop. If it is, you need to break the loop and continue. Operators I would use: == to check if answer is equal to number generated.

Program purpose: Fun game about guessing a random number

Useful in real world: (I can't think of anything for this one)

Errors: I didn't run into any errors.

Differently: I think I wrote my program as efficiently as I could.

Step-by-step explanation:

I could program this "game" for you if you tell me what language it needs to be made in. I.E Python, C++, lua, etc.

Good luck! P.S, Please do not COPY + PASTE this answer, it will most likely be found by whoever is checking this. There is 1-2 things in there you will need to change to your liking.

User Maelstrom
by
5.9k points