# Small problem with looping program

Microsoft Windows vista home premium sp1...
February 1, 2010 at 19:47:03
Specs: Windows Vista
 Well, Ive never tried to code anything on my own before. I actually just began trying to learn how to program in C++ yesterday, using online tutorials. Today, i decided to apply what i had learned and try to make a "game."```#include using namespace std; main () { int EXP = 0 , NEEDEDEXP = 4, LEVEL = 1, POWER = ( LEVEL * 2 ), INPUTTEDNUMBER; cout<< " RUNESCAPE LEVELING SIMULATOR!\n"; cout<< "Welcome. Lets see what level you can get to! If you forgot, use 1-5 and enter to harvest wood. enter anything not 1-5 to find out your current level\n"; top: cin>> INPUTTEDNUMBER; if ( INPUTTEDNUMBER == ( 1,2,3,4,5 ) ) { EXP + POWER; if ( NEEDEDEXP <= EXP ) { NEEDEDEXP * 4; LEVEL + 1; goto top; } else { goto top; } } else { cout<< "YOU ARE LEVEL" << LEVEL <

See More: Small problem with looping program

#1
February 1, 2010 at 20:52:49
 The biggest problem I can find is that the math it's doing doesn't assign to anything.```NEEDEDEXP * 4; ```Needs to be:```NEEDEDEXP = NEEDEDEXP * 4; ```or```NEEDEDEXP *= 4; ```I also removed the goto/label and replaced it with a while loop. Where you were using "goto top;" you can used "continue;" instead, to exit "iterate = false;" or "break;".```#include using namespace std; int main () { int EXP = 0 , NEEDEDEXP = 4, LEVEL = 1; int POWER = ( LEVEL * 2 ), INPUTTEDNUMBER; cout << " RUNESCAPE LEVELING SIMULATOR!" << endl; cout << "Welcome. Lets see what level you can get to! " << "If you forgot, use 1-5 and enter to harvest" << "wood. enter anything not 1-5 to find out your" << "current level" << endl; bool iterate = true; while (iterate) { cin >> INPUTTEDNUMBER; if ( INPUTTEDNUMBER > 0 && INPUTTEDNUMBER < 6 ) { EXP += POWER; if ( NEEDEDEXP <= EXP ) { NEEDEDEXP *= 4; LEVEL++; } } else { cout<< "YOU ARE LEVEL" << LEVEL <

Report •

#2
February 1, 2010 at 21:26:31
 just basic concepts, but you'll get the hang:var assignment always involves placing the var. name on the left of the assignment (C, and most other langs it's "=", in pascal its ":=")f/e: level+1doesn't do anything (or not that i can tell). All your var. assignments need be like:level=level+1or (in C and some others:)level+=1orlevel++but C will let you do it the "traditional" way as well (level=level+1)and i don't know what this does or is supposed to do or doesn't do:if ( INPUTTEDNUMBER == ( 1,2,3,4,5 ) )i thought it was someting i didn't know about in C and took it to mean: if number is 1 or 2 or 3 or 4 or 5...but that didn't seem to work (i had to try it because i'm also very new at C, just breaking the ice so to speak)So i'm clueless what you meant by that program-statement.Also, the power level, which i would assume to be a multiplier for the EXP, never gets upgraded with level-up, but i'm not clear enough about your game concept to know what you intended.good start though, didn't generate a single compiler error, unlike my first several feeb attempts which usually didn't get past line 2 before blowing up.(oops, crossed in the mail, sorry Judago!)

Report •

#3
February 1, 2010 at 21:30:40
 (oops, crossed in the mail, sorry Judago!)No problem, it happens ;)Batch Variable how to

Report •

Related Solutions

#4
February 2, 2010 at 12:04:28
 I would like to thank you all, especially nbrane. While i kept it as a GOTO (im still figuring out while loops), i was using NEEDED EXP * 4 = NEEDEDEXP ;instead of NEEDEDEXP = NEEDEDEXP * 4; .Thanks for the tip.

Report •