Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 number game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
VB3CK




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
BigBear




PostPosted: 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
andrew.




PostPosted: 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?
saltpro15




PostPosted: 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?
andrew.




PostPosted: 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
saltpro15




PostPosted: 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
saltpro15




PostPosted: 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
Tony




PostPosted: Tue Feb 24, 2009 4:28 pm   Post subject: RE:number game

hey guys, lets review

Do not post full solutions to homework assignments.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
saltpro15




PostPosted: Tue Feb 24, 2009 4:28 pm   Post subject: RE:number game

sorry Tony Embarassed won't happen again
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: 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
VB3CK




PostPosted: 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
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: