Computer Science Canada help with random number |
Author: | asianrandy [ Mon Oct 27, 2008 12:37 pm ] |
Post subject: | help with random number |
i need to learn about random number, so i can ready for to making a guessing game for my assignment. please and thank you |
Author: | Insectoid [ Mon Oct 27, 2008 1:46 pm ] |
Post subject: | RE:help with random number |
Go into Turing and press F10. If that doesn't work, look through the Turing Walkthrough. |
Author: | andrew. [ Mon Oct 27, 2008 3:06 pm ] |
Post subject: | RE:help with random number |
Like insectoid said, go into Turing and press F10. Search for randint and Rand.Int. Those should help you out. Also, this should be in the Turing Help, not the Tutorials. |
Author: | Tony [ Mon Oct 27, 2008 3:09 pm ] |
Post subject: | RE:help with random number |
moved to Turing Help. Also -- it's Rand.Int(). (randint is deprecated) |
Author: | asianrandy [ Tue Oct 28, 2008 12:07 pm ] |
Post subject: | Re: help with random number |
am sorry |
Author: | asianrandy [ Tue Oct 28, 2008 12:27 pm ] | ||
Post subject: | RE:help with random number | ||
i need help, the user the has $10 and if the user gets it wrong the user will lose 1, everytime the user get it wrong. |
Author: | jbking [ Tue Oct 28, 2008 12:32 pm ] |
Post subject: | RE:help with random number |
Don't you need to declare a couple of variables outside the loop, e.g. $ of user and # of random numbers to be guessed? Within the loop, it should be simple enough to keep track of what the user's money is by subtracting one if the guess is wrong. |
Author: | asianrandy [ Wed Oct 29, 2008 12:01 pm ] |
Post subject: | RE:help with random number |
what the code for that |
Author: | jbking [ Wed Oct 29, 2008 3:41 pm ] | ||
Post subject: | Re: help with random number | ||
Here's your code with the few lines added for what I mean:
So, the main changes are: Decrement the money and increment the count as the user enters a number Change the condition when the user gets a number right to see if the number of numbers is done or not. Check at the end of the loop to see there is still money to play the game |
Author: | asianrandy [ Wed Oct 29, 2008 3:49 pm ] |
Post subject: | Re: help with random number |
there was an error for the put "Congratulations, you are a winner" and put "You are broke, sorry". |
Author: | isaiahk9 [ Wed Oct 29, 2008 6:51 pm ] |
Post subject: | RE:help with random number |
you need a "Then" on the ifs above the two lines you pointed out. |
Author: | asianrandy [ Thu Oct 30, 2008 12:29 pm ] |
Post subject: | RE:help with random number |
thanks |
Author: | isaiahk9 [ Thu Oct 30, 2008 3:27 pm ] |
Post subject: | RE:help with random number |
np |
Author: | asianrandy [ Fri Oct 31, 2008 1:04 pm ] |
Post subject: | RE:help with random number |
i trying to figure out how to show how much money does user have on every question the user guess. i can't figure it out, l'm a noob at this ok. |
Author: | jbking [ Fri Oct 31, 2008 3:14 pm ] | ||||
Post subject: | Re: help with random number | ||||
We were all noobs once, so here is the help on that: Notice the line:
Which displays the number of times it took someone to get the right answer? Well that has what you need to do for the money part as it should be as simple as adding this line before the "Enter your guess" line:
Or at least that would be my initial suggestion. While I haven't programmed in Turing I can pick up some basics and translate code from language to language at times pretty easily. |
Author: | asianrandy [ Fri Oct 31, 2008 5:58 pm ] |
Post subject: | RE:help with random number |
thanks man |