----------------------------------- marz Mon Jun 02, 2003 7:49 pm help with numbers game again! ----------------------------------- Alright, For this number game that we are doing, we must make the game exit when the user takes 10 guesses. I dont know how to do this, or what codes to use. Here is my programming so far. ----------------------------------- ShadowStorm Mon Jun 02, 2003 9:11 pm ----------------------------------- Here's the source code of a program i made a while back.. hope this helps... const SECRET_NUMBER := Rand.Int(1,100) var counter : int := 0 var userGuess : int loop put "Guess a number from 1 to 100 " get userGuess if userGuess > SECRET_NUMBER then put "YOUR GUESS IS TOO HIGH!" put skip elsif userGuess < SECRET_NUMBER then put "YOUR GUESS IS TOO LOW!" put skip end if counter := counter + 1 exit when counter >= 10 exit when userGuess = SECRET_NUMBER end loop if userGuess = SECRET_NUMBER then put "YOU WIN!!" elsif counter >= 10 then put "YOU LOSE!!" end if ----------------------------------- marz Mon Jun 02, 2003 10:23 pm ----------------------------------- :) Thanks for the code. It gave me a new perspective on how to do the numbers game. However, i still need to know how to make the game exit when the user has taken 10 guesses. Also, it has to say instead of "you have taken one guess so far", it has to say "you only have 9 guesses left." PLEASE HELP! :( ----------------------------------- Dan Tue Jun 03, 2003 12:03 am ----------------------------------- ah, i think his code dose that and i whould hop you know how to chage/add the put stamtes you need. ----------------------------------- Blade Tue Jun 03, 2003 11:18 am ----------------------------------- theres two ways you can do this: first of all you make a variable that contains the amount of guesses and in your case you would set it to ten. in the if statement where you check to see if the's guessed the answer. if its wrong. subtract one from the total giving him 9. use this variable in your put statement to tell them how many you have left. also. in your loop have exit when chances = 0 var chances:int:=10 loop put "You have ",chances," left" %your if statement checking to see if he has the right answer %if not subtract one from chances exit when chances = 0 end loop the other way is to run a decreasing for loop from 10 and also have a condition to exit when he gets the right answer for decreasing i:10..0 put "you have ",i," chances left" %exit when dude has the right answer end for ----------------------------------- Andy Tue Jun 03, 2003 2:11 pm ----------------------------------- ha, i made that program on the ti 83 plus calculator