Computer Science Canada

lotto 649

Author:  GUI.GetScrollBarWidth : i [ Wed Feb 18, 2004 12:04 pm ]
Post subject:  lotto 649

var num1, num2, num3, num4, num5, num6, numm1, numm2, numm3, numm4, numm5, numm6 : int
var c1, c2, c3, c4, c5, c6 : int := 0
cls
put "play lotto649."
put "the 649 is how many millions of $ we steal"
loop
randint (num1, 1, 49)
randint (num2, 1, 49)
randint (num3, 1, 49)
randint (num4, 1, 49)
randint (num5, 1, 49)
randint (num6, 1, 49)
if num1 not= num2
and num1 not= num3
and num1 not= num4
and num1 not= num5
and num1 not= num6
and num2 not= num3
and num2 not= num4
and num2 not= num5
and num2 not= num6
and num3 not= num4
and num3 not= num5
and num3 not= num6
and num4 not= num5
and num4 not= num6
and num5 not= num6
then
exit
end if
end loop
put "enter your first number"
get numm1
put "enter your second number"
get numm2
put "enter your third number"
get numm3
put "enter your fourth number"
get numm4
put "enter your fifth number"
get numm5
put "enter your sixth number"
get numm6
cls
cls
put "the winning numbers are:"
put " ", num1, " ", num2, " ", num3, " ", num4, " ", num5, " ", num6
put ""
put "your numbers are"
put " ", numm1, " ", numm2, " ", numm3, " ", numm4, " ", numm5, " ", numm6
var pic := Pic.FileNew ("lotto pic3.bmp")
Pic.Draw (pic, 0, 50, picCopy)
if num1 = numm1 then
put
"you got the first number right"
else
put "you got the first number wrong"
if num2 = numm2 then
put "you got the second number right"
else
put "you got the second number wrong"
if num3 = numm3 then
put "you got the third number right"
else
put "you got the third number wrong"
if num4 = numm4 then
put "you got the foruth number right"
else
put "you got the foruth number wrong"
if num5 = numm5 then
put "you got the fifth number right"
else
put "you got the fifth number wrong"
if num6 = numm6 then
put "you got the sixith number right"
else
put "you got the sixith number wrong"
end if
end if
end if
end if
end if
end if

i'm bord so i posted this, imade it for school

Author:  Paul [ Wed Feb 18, 2004 8:59 pm ]
Post subject: 

Keep trying lucas, good start, here's some bits so you wouldn't say "Gymasium" anymore.

Author:  Scorne [ Mon Jun 28, 2004 11:06 pm ]
Post subject:  Randomizing numbers for whatever reason.

I did this stuff 4 years ago and forget how..

How would i make a program to Randomize (3,6,12,24) numbers(1 set)
from like (X amount) sets of 12 numbers..

So i input x (120, 60, etc numbers).. to create (3,6,12,24) numbers

Catch my drift..?

Just to make sure its all smooth..

------
"How many Numbers do you want Randomized?"
(3,6,12,24)
"How many Sets of (3,6,12,24) will be randomized?"
(3,6,12,24)
"Please input the first (3,6,12,24) digits"
768645
" "
" "
"Please input the last (3,6,12,24) digits"
877678

"From those numbers "
999999 was generated

Author:  Tony [ Tue Jun 29, 2004 12:12 am ]
Post subject: 

wow, I'm lost... your problem doesnt seem to make any sence...

and how does it have anything to do with a lottery game? Confused

Author:  Cervantes [ Tue Jun 29, 2004 9:42 am ]
Post subject: 

umm, "lucas", if that's your name: your if statements at the end are all wrong. Confused
here's why:
starting at line 51:
if the number you picked equals the first number of the lottery then put "you got the first number right" and skip the entire else section and continue the program at end if. so even if you got all 5 of the other numbers right, the program still won't output that you got them right if you got the first number right.
you could fix this by doing something like this:
code:

var lotto_num : array 1 .. 6 of int
var picked_num : array 1 .. 6 of int
var correct_num : array 1 .. 6 of boolean
for i : 1 .. 6
    correct_num (i) := false %initializing all elements of correct_num to false
end for
var exit_loop : boolean

% generating the numbers.  most of this is to ensure that no 2 numbers are the same.
for l : 1 .. 6
    loop
        exit_loop := true
        lotto_num (l) := Rand.Int (1, 49)
        for decreasing c : l - 1 .. 1
            if lotto_num (l) = lotto_num (c) then
                exit_loop := false
            end if
        end for
        exit when exit_loop
    end loop
end for

for p : 1 .. 6
    put "Enter number ", p, " : " ..
    loop
        exit_loop := true
        locate (p, 17)
        get picked_num (p)
        if picked_num (p) < 1 or picked_num (p) > 49 then
            exit_loop := false
        end if
        for c : 1 .. p - 1
            if picked_num (c) = picked_num (p) then
                exit_loop := false
            end if
        end for
        exit when exit_loop
        locate (p, 17)
        put "                           " %covers up prevously enter number.  this line is not executed it exit_loop is true coming out of the for loop
    end loop
end for

cls

put "the winning numbers are:"
for l : 1 .. 6
    put " ", lotto_num (l) ..
end for
put ""
put ""
put "your numbers are"
for p : 1 .. 6
    put " ", picked_num (p) ..
end for
put ""

%%CHECKING users numbers against the generated numbers%%
for p : 1 .. 6
    for l : 1 .. 6
        if picked_num (p) = lotto_num (l) then
            correct_num (p) := true
        end if
    end for
end for

for f : 1 .. 6
    if correct_num (f) then     % same as    if correct_num (f) = true then
        put "you got your ", f, "th number RIGHT.  you picked ", picked_num (f), "."
    else
        put "you got your ", f, "th number WRONG.  you picked ", picked_num (f), "."
    end if
end for

Author:  the_short1 [ Tue Jun 29, 2004 3:25 pm ]
Post subject: 

also the arrays are very useful in this... <cervants just added them rite?






but other then that.... i like ur program... nice ... simple.. and to the point..


some suggestions: (just suggestions)

-Add a ball tumbler animation
-Add GUI Buttons <since thats in ur name Razz
-Maybe add a GUI keypay to enter the numbers (pm me if u want the source code)
-add some color...

Author:  Paul [ Tue Jun 29, 2004 3:48 pm ]
Post subject: 

yea... look at the date on that thing... plus I know that he's prolly not coming back to compsci again and not programming again.


: