Computer Science Canada

number game

Author:  VB3CK [ Tue Feb 24, 2009 3:04 pm ]
Post subject:  number game

Ok I got this question or homework
And I got no clue What to do

8. Create a small game where you instruct person 1 to enter a number between 1 and 10. Then ask the second user to guess the number. You should tell the user that they were either too high, too low, or got it.

Author:  BigBear [ Tue Feb 24, 2009 4:11 pm ]
Post subject:  Re: number game

Just break down what is asked. Also you should have posted some code to see what area you need help with.

You only need to use put, get and maybe if statements

Author:  andrew. [ Tue Feb 24, 2009 4:16 pm ]
Post subject:  RE:number game

Let's break it down:
1. Get a number
2. Get another number
3. Check if the number is high, low, or right

Doesn't seem too hard once you break it down, eh?

Author:  saltpro15 [ Tue Feb 24, 2009 4:17 pm ]
Post subject:  Re: number game

now this is the ONLY time I will ever do this

Code Removed

next time, post some code and we'll try to help you


Mod Edit: Why are you just giving him the solution?

Author:  andrew. [ Tue Feb 24, 2009 4:19 pm ]
Post subject:  Re: number game

saltpro15 @ Tue Feb 24, 2009 4:17 pm wrote:
now this is the ONLY time I will ever do this

Code Removed


next time, post some code and we'll try to help you[/quote]What's the point of the variable "guess2" and the delay (100)?

Mod Edit: Removing code that is of no need

Author:  saltpro15 [ Tue Feb 24, 2009 4:24 pm ]
Post subject:  RE:number game

guess 2 i forgot to delete, and the delay is just style lol

Author:  saltpro15 [ Tue Feb 24, 2009 4:27 pm ]
Post subject:  RE:number game

@ mod
so he can learn, other people's code is the only way I ever learned, if he hands it in well he's only hurting himself, I don't care

Author:  Tony [ Tue Feb 24, 2009 4:28 pm ]
Post subject:  RE:number game

hey guys, lets review

Do not post full solutions to homework assignments.

Author:  saltpro15 [ Tue Feb 24, 2009 4:28 pm ]
Post subject:  RE:number game

sorry Tony Embarassed won't happen again

Author:  Tony [ Tue Feb 24, 2009 4:30 pm ]
Post subject:  Re: RE:number game

saltpro15 @ Tue Feb 24, 2009 4:27 pm wrote:
@ mod
so he can learn, other people's code is the only way I ever learned

There was enough "code" posted to figure the problem out by andrew
andrew. @ Tue Feb 24, 2009 4:16 pm wrote:
Let's break it down:
1. Get a number
2. Get another number
3. Check if the number is high, low, or right


Edit: that is, andrew's reply is the expected response. If there are more problems (like "what syntax do I use to get user input?"), then such should be asked in follow-up questions.

Author:  Insectoid [ Tue Feb 24, 2009 5:49 pm ]
Post subject:  RE:number game

First of all, get the first number.

code:

get num1


then, get the second.

code:

get num1
get num2


then, use the greater than/less than/equal too operators (>, <, =) (hope none of those turn into smileys...). If the number is too high, is it to greater than or less than? If we flip that around,

if the number is greater than the guess, output "too high". If it is less than the guess, output "Too low", if it is equal, output "Bang on!".

Remember your conditionals,

code:

if this > that then
    %do stuff
elsif this < that then
    %do something else
else
    %do something else
end if

Author:  VB3CK [ Wed Feb 25, 2009 9:58 am ]
Post subject:  RE:number game

thank you all for your help!

Yep it's easier if you break it down like posters said above.

And thanks insectoid for the hint.

THis was easier than I thought


: