C++ Final Program Assisttance Needed

I'm a c++ student who is very lost. I have a final program to do but I don't know when to start. If anybody can complete the program or help me out it will be highly appreciated.

Here is the assignment.


Write a program where the user guesses a number between 1-20. Have the user guess the number and tell them whether their guess is “cold” (more than 5 numbers away), “warm” (3-5 numbers away), “hot” (1-2 numbers away) or correct.

When they have successfully guessed the correct number, you should tell them how many guesses it took them and allow them to play again if they’d like.

(You may set your random number in the program, but find a way to change it if they play again – suggestion: Find a way to change your original number but keep between 1-20 by using %)
closed account (S6k9GNh0)
No. You aren't even trying. Go back to the book if you can't figure out something that basic.
computerquip *= 2. This problem is very easy in contrast to most other final programs I've seen on this forum. That said, write out some C-like psuedo-code and work your way from there. If you can't figure that out, then there's not much we will do for you, and you should check the books. Think of it as tough love.

-Albatross
I can totally solve this for you post your souce ;)
No. No. Solving something for someone is in direct violation of this forum's spirit. Help with syntax and minor formulation errors yes, but solving the whole problem for someone... unless you meant something else.

-Albatross
If this is Your final one... And You don´t know where to start... Then, well..., You ARE really lost!
If this is your final one...
What did you see in your class the whole year??
I'm studying c++ on my own for about two weeks now and i can solve that...
@Albatross, My Apologies. It <b>won't</b> happen again
@Albatross: You know lampshade was making a joke right? As in if OP posts their source, then lampshade will just say that is the answer.
...something was odd about solving something for someone after that someone posted that solution, but just to be sure, I put that in.

Okay, I'm going to actually be a little bit helpful here to the OP. Here's a tutorial:
http://cplusplus.com/doc/tutorial/

You only need to read up to and excluding Functions (I) to solve this problem, but every section up to that point has something critical to learn that you cannot write that program without. After you read those and UNDERSTAND them, try to solve your problem again.

-Albatross

P.S.- Alternatively, I could write out a full solution for you that is going to use instances of inline assembly, several exceptions in place of basic control statements, polymorphism and virtualization within templates, a wrapper for cstdio using multiple operator overloads, several instances of recursion within the template's member functions dependent on a thrown exception, and at least one use of the void* type.
Last edited on
lol at Alba's P.S
I'm a c++ student who is very lost. I have a final program to do but I don't know when to start. If anybody can complete the program or help me out it will be highly appreciated.

I assume that you are familiar with c++ since this is your final program. If you didn't tell the truth about that, which means you are a beginner, then I'll direct you to the tutorial, like Albatross did:

http://cplusplus.com/doc/tutorial/

Else...

Write a program where the user guesses a number between 1-20. Have the user guess the number and tell them whether their guess is “cold” (more than 5 numbers away), “warm” (3-5 numbers away), “hot” (1-2 numbers away) or correct.

I would implement the guessing process as a while (or for) loop with some if (or switch) statement(s) inside to check how close the user's guess is to the target number:

http://cplusplus.com/doc/tutorial/control/

Function abs() found inside cmath could be useful to check the distance of the user's guess from the target number:

http://cplusplus.com/reference/clibrary/cstdlib/abs/

When they have successfully guessed the correct number, you should tell them how many guesses it took them and allow them to play again if they’d like.

An integer initialized to zero and increased by one with every iteration inside your loop would be just fine for this one.

(You may set your random number in the program, but find a way to change it if they play again – suggestion: Find a way to change your original number but keep between 1-20 by using %)

rand(), srand() and time() would be usefull here (include cstdlib and ctime):

http://cplusplus.com/reference/clibrary/cstdlib/rand/
http://cplusplus.com/reference/clibrary/cstdlib/srand/
http://cplusplus.com/reference/clibrary/ctime/time/

I assume that you know how to use the % operator. If you don't look it up here:

http://cplusplus.com/doc/tutorial/operators/
Topic archived. No new replies allowed.