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

Username:   Password: 
 RegisterRegister   
 Problem with lottery numbers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
blankout




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




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




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




PostPosted: Fri Apr 03, 2009 5:28 pm   Post subject: RE:Problem with lottery numbers

Jeez, use arrays and for loops!! Checkout the Turing Walkthrough.
Insectoid




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




PostPosted: 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...
Dusk Eagle




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




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




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




PostPosted: Sat Apr 04, 2009 7:48 pm   Post subject: Re: Problem with lottery numbers

true
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  [ 10 Posts ]
Jump to:   


Style:  
Search: