Beginner turing help (counters)
Author |
Message |
jadelinanne
|
Posted: Tue Dec 11, 2012 5:48 pm Post subject: Beginner turing help (counters) |
|
|
What is it you are trying to achieve?
I am taking a beginner course on programming and because I was sick, I missed a week and I need some help The assignment says to :
Create a guessing game where the player will have to guess 3 numbers that are randomly chosen by the computer. The 3 random numbers should be between 1 and 10. The user will start off with a certain amount of money, which you will determine ( i chose 10).
Each time the user guesses ,it should cost them 1$. Your program should also keep track of how many guesses they took.
The program should end when the user either guesses all 3 numbers correctly or runs out of money. when the program ends it should ask the user whether or not they want to play again.
The program should tell whether the user matched any numbers or if they haven't matched any at all (Do not tell which number they matched)
The user should get a certain amount of money for guessing a number correctly. if the user guesses all 3 numbers correctly then they should get 15$. if they get 2 correct, they get 3$. if they get 1 correct, they should get 2$.
The user should NOT get money if they dont guess any numbers right. The amount of money the user has left should always be shown on the screen so they can know how many more guesses they are gonna get. Your program should also display how much money the user has won, if any.
>
What is the problem you are having?
as the loop goes on, more guesses are made and I can't get the program to subtract 1 dollar off of every guess
what do I do?
>
Please specify what version of Turing you are using
<4.11> |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Panphobia
![](http://compsci.ca/v3/uploads/user_avatars/62033050050c6b61548706.png)
|
Posted: Tue Dec 11, 2012 5:54 pm Post subject: RE:Beginner turing help (counters) |
|
|
show the code, you probably need an if |
|
|
|
|
![](images/spacer.gif) |
jadelinanne
|
Posted: Tue Dec 11, 2012 6:07 pm Post subject: RE:Beginner turing help (counters) |
|
|
This is what I have so far
loop
startingAmount := startingAmount - 3
put "What do you think the first number is?"
get input1
put " "
put "What do you think the second number is?"
get input2
put " "
put "what do you think the third number is?"
get input3
put " "
count := count + 3
if input1= gen1 and input2 = gen2 and input3 = gen3 then
startingAmount := Amount + 15
put
"Congrats! You got them all right!"
put "Winning: 15 dollars"
put "Balance:", startingAmount, "dollars"
exit when input1 = gen1 and input2 = gen2 and input3 = gen3 or startingCash = 0
elsif input1 = generate1 and guess2 = gen2 then
startingCash := startingAmount + 3
put "You got two numbers correct"
put "Winning:3 dollars"
put "Balance:", startingAmount, "dollars"
elsif input1 = gen1 and guess3 = gen3 then
startingAmount := startingAmount + 3
put "You got two numbers correct"
put "You got two numbers correct"
put "Winning:3 dollars"
put "Balance: ", startingAmount, "dollars"
elsif guess2 = gen2 and guess3 = gen3 then
startingAmount := startingAmount + 3
put "You got two numbers correct"
put "You got two numbers correct"
put "Winning:3 dollars"
put "Balance: ", startingCash, "dollars"
elsif input1 = gen1 then
startingAmount := startingAmount + 2
put "You got one number correct"
elsif guess2 = gen2 then
st startingAmount := startingAmount + 2
put "You got one number correct"
elsif guess3 = gen3 then
startingAmount := startingAmount + 2
put "You got one number correct"
put "You got it in", count, "guesses"
end if
end loop |
|
|
|
|
![](images/spacer.gif) |
Panphobia
![](http://compsci.ca/v3/uploads/user_avatars/62033050050c6b61548706.png)
|
Posted: Tue Dec 11, 2012 6:12 pm Post subject: Re: Beginner turing help (counters) |
|
|
I am not going to code it for you but you should consider totally scrapping your code and make it input a starting amount then, make a counter that represents the question you are on, and then check if the number is equal to one of the three numbers, if it is add 1 to wins and take the number out of being checked, and then repeat until startamount := 0 or wins = 3 and then at the end just make an if, if wins = 1 then.... elsif wins =2, oh ya and after every input just do startAmount -=1 |
|
|
|
|
![](images/spacer.gif) |
jadelinanne
|
Posted: Tue Dec 11, 2012 6:17 pm Post subject: RE:Beginner turing help (counters) |
|
|
How do I get the number out of being checked? |
|
|
|
|
![](images/spacer.gif) |
Panphobia
![](http://compsci.ca/v3/uploads/user_avatars/62033050050c6b61548706.png)
|
Posted: Tue Dec 11, 2012 6:19 pm Post subject: RE:Beginner turing help (counters) |
|
|
figure it out ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
jadelinanne
|
Posted: Tue Dec 11, 2012 6:31 pm Post subject: RE:Beginner turing help (counters) |
|
|
THANK YOU! ;D! |
|
|
|
|
![](images/spacer.gif) |
|
|