Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Calculator to Favorite Number

Name: Anonymous 2012-10-19 16:20

Just started a C++ course and I was told to change the calculator I just made into a guessing my favorite number, if the answer is not correct the computer is not supposed to do anything.

I can't find any instruction on this and am pretty clueless on what to do.

http://pastebin.com/SUxYD4ZA

Name: Anonymous 2012-10-19 17:29

bump

Name: Anonymous 2012-10-19 17:33

youre a jew

Name: Anonymous 2012-10-19 17:34

You're going to need a way of generating a random integer in a range of values. 

Here's some pseudopseudocode that may or may not be right:

START INFINITE WHILE LOOP
- Generate a random number in a certain range (say, 1-10).
- Print random number.
- bool MATCH = Prompt user for TRUE/FALSE match of favorite number
- IF (MATCH == TRUE) {"COMPUTER READS YOUR MIND"; BREAK;}
  ELSE {// DO NOTHING AND REPEAT NEXT ITERATION OF THE LOOP}
END INFINITE WHILE LOOP

That should at least get you going.  I don't code C++, so you're on your own.  I did this shit back when I was 15, and it's a good indicator if you're cut out to be a codemonkey.  Make sure your variables are integers, generate a random number that's an integer, etc.

Name: Anonymous 2012-10-19 17:37

Sepples        ☑
homework       ☑
clueless       ☑
not using sage ☑


back to /g/, please.

Name: Anonymous 2012-10-19 17:43

My favorite number is 31.

Name: Anonymous 2012-10-19 17:52

My favorite number is π³.

Don't change these.
Name: Email:
Entire Thread Thread List