Problem with lottery numbers
Author |
Message |
blankout
|
Posted: Fri Apr 03, 2009 4:50 pm Post subject: Problem with lottery numbers |
|
|
when i get to the final screen, only the first line that says "you are wrong" shows up
can someone help me with getting the final few lines to appear
Code: | var random, random2, random3, random4, random5:int
var counter, counter2, counter3, counter4, counter5:int:=0
var number, number2:int:=0
var num1, num2, num3, num4, num5:int
get num1
get num2
get num3
get num4
get num5
cls
loop
locate (1,1)
randint(random, 1, 100)
put random
randint(random, 1, 100)
delay (10)
counter:=counter+1
randint (number, 50, 100)
exit when counter=75
end loop
loop
locate (1,5)
randint(random2, 1, 100)
put random2
randint(random2, 1, 100)
delay (10)
counter2:=counter2+1
exit when counter2=75
end loop
loop
locate (1,10)
randint(random3, 1, 100)
put random3
randint(random3, 1, 100)
delay (10)
counter3:=counter3+1
exit when counter3=75
end loop
loop
locate (1,15)
randint(random4, 1, 100)
put random4
randint(random4, 1, 100)
delay (10)
counter4:=counter4+1
exit when counter4=75
end loop
loop
locate (1,20)
randint(random5, 1, 100)
put random5
randint(random5, 1, 100)
delay (10)
counter5:=counter5+1
exit when counter5=75
end loop
cls
put "You Picked"
put num1
put num2
put num3
put num4
put num5
locate (1, 15)
put "The Winning Numbers Are"
locate (2, 25)
put random
locate (3, 25)
put random2
locate (4, 25)
put random3
locate (5, 25)
put random4
locate (6, 25)
put random5
if num1=random
then
locate (2, 30)
put "You are Right!"
elsif num2=random2
then
locate (3, 30)
put "You are Right!"
elsif num3=random3
then
locate (4, 30)
put "You are Right!"
elsif num4=random4
then
locate (5, 30)
put "You are Right!"
elsif num5=random5
then
locate (6, 30)
put "You are Right!"
elsif num1 not= random
then
locate (2, 30)
put "You Are Wrong!"
elsif num2 not= random2
then
locate (3, 30)
put "You Are Wrong!"
elsif num3 not= random3
then
locate (4, 30)
put "You Are Wrong!"
elsif num4 not= random4
then
locate (5, 30)
put "You Are Wrong!"
elsif num5 not= random5
then
locate (6, 30)
put "You Are Wrong!"
end if
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
Posted: Fri Apr 03, 2009 4:57 pm Post subject: RE:Problem with lottery numbers |
|
|
Turing: |
if num1=random
then
locate (2, 30)
put "You are Right!"
elsif num2=random2
then
locate (3, 30)
put "You are Right!"
elsif num3=random3
then
locate (4, 30)
put "You are Right!"
elsif num4=random4
then
locate (5, 30)
put "You are Right!"
elsif num5=random5
then
locate (6, 30)
put "You are Right!"
elsif num1 not= random
then
locate (2, 30)
put "You Are Wrong!"
elsif num2 not= random2
then
locate (3, 30)
put "You Are Wrong!"
elsif num3 not= random3
then
locate (4, 30)
put "You Are Wrong!"
elsif num4 not= random4
then
locate (5, 30)
put "You Are Wrong!"
elsif num5 not= random5
then
locate (6, 30)
put "You Are Wrong!"
end if
|
BAD, your problem is probably in that giant mess |
|
|
|
|
![](images/spacer.gif) |
blankout
|
Posted: Fri Apr 03, 2009 5:25 pm Post subject: Re: Problem with lottery numbers |
|
|
k i got the answer, i guess the whole solution was simply that is was just one giant mess of code
Turing: | if num1 = random
then
locate (2, 30)
put "You are Right!"
else
locate (2, 30)
put "You're Wrong!"
end if
if num2 = random2
then
locate (3, 30)
put "You're Right!"
else
locate (3, 30)
put "You're Wrong!"
end if
if num3 = random3
then
locate (4, 30)
put "You're Right!"
else
locate (4, 30)
put "You're Wrong!"
end if
if num4 = random4
then
locate (5, 30)
put "You're Right!"
else
locate (5, 30)
put "You're Wrong!"
end if
if num5 = random5
then
locate (6, 30)
put "You're Right!"
else
locate (6, 30)
put "You're Wrong!"
end if
|
|
|
|
|
|
![](images/spacer.gif) |
CodeMonkey2000
|
Posted: Fri Apr 03, 2009 5:28 pm Post subject: RE:Problem with lottery numbers |
|
|
Jeez, use arrays and for loops!! Checkout the Turing Walkthrough. |
|
|
|
|
![](images/spacer.gif) |
Insectoid
![](http://compsci.ca/v3/uploads/user_avatars/13760332514cbd0ce972eaa.jpg)
|
Posted: Fri Apr 03, 2009 9:59 pm Post subject: RE:Problem with lottery numbers |
|
|
I can see this done with a procedure, an array and a for loop in about 10 lines.
code: |
var nums : array 1..5 of int
var guess : array 1..5 of int
for x: 1..5
nums (x) := Rand.Int (1, 100)
get guess (x)
if guess (x) = nums (x) then
put "Correct!"
else
put "Wrong!"
end for
|
|
|
|
|
|
![](images/spacer.gif) |
blankout
|
Posted: Sat Apr 04, 2009 6:54 pm Post subject: Re: Problem with lottery numbers |
|
|
that doesnt really work insectoid, you simply enter a number and it immediatly says wrong... |
|
|
|
|
![](images/spacer.gif) |
Dusk Eagle
![](http://compsci.ca/v3/uploads/user_avatars/78727197549dd7290a342c.png)
|
Posted: Sat Apr 04, 2009 7:14 pm Post subject: Re: Problem with lottery numbers |
|
|
What are you talking about? Insectoid's code, once you fix one syntax error, works perfectly. |
|
|
|
|
![](images/spacer.gif) |
blankout
|
Posted: Sat Apr 04, 2009 7:40 pm Post subject: Re: Problem with lottery numbers |
|
|
only to a certain extent, once you do add the 'end if' you enter a number, but you only ever see the final result, the number or in this case 'num', is never shown, so you only get the message saying either wrong or right |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
saltpro15
![](http://compsci.ca/v3/uploads/user_avatars/9776171634ced6278d14c2.png)
|
Posted: Sat Apr 04, 2009 7:47 pm Post subject: RE:Problem with lottery numbers |
|
|
but it can be easily modified to output num
Turing: |
var nums : array 1..5 of int
var guess : array 1..5 of int
for x: 1..5
nums (x) := Rand.Int (1, 100)
get guess (x)
if guess (x) = nums (x) then
put "Correct!"
else
put "Wrong!"
put nums(x)
end if
end for
|
|
|
|
|
|
![](images/spacer.gif) |
blankout
|
Posted: Sat Apr 04, 2009 7:48 pm Post subject: Re: Problem with lottery numbers |
|
|
true |
|
|
|
|
![](images/spacer.gif) |
|
|