
-----------------------------------
blankout
Fri Apr 03, 2009 4:50 pm

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

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


-----------------------------------
saltpro15
Fri Apr 03, 2009 4:57 pm

RE:Problem with lottery numbers
-----------------------------------

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

-----------------------------------
blankout
Fri Apr 03, 2009 5:25 pm

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

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


-----------------------------------
CodeMonkey2000
Fri Apr 03, 2009 5:28 pm

RE:Problem with lottery numbers
-----------------------------------
Jeez, use arrays and for loops!! Checkout the Turing WalkThrough.

-----------------------------------
Insectoid
Fri Apr 03, 2009 9:59 pm

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
[/code]

-----------------------------------
blankout
Sat Apr 04, 2009 6:54 pm

Re: Problem with lottery numbers
-----------------------------------
that doesnt really work insectoid, you simply enter a number and it immediatly says wrong...

-----------------------------------
Dusk Eagle
Sat Apr 04, 2009 7:14 pm

Re: Problem with lottery numbers
-----------------------------------
What are you talking about? Insectoid's code, once you fix one syntax error, works perfectly.

-----------------------------------
blankout
Sat Apr 04, 2009 7:40 pm

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

-----------------------------------
saltpro15
Sat Apr 04, 2009 7:47 pm

RE:Problem with lottery numbers
-----------------------------------
but it can be easily modified to output num

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 


-----------------------------------
blankout
Sat Apr 04, 2009 7:48 pm

Re: Problem with lottery numbers
-----------------------------------
true
