649 Lottery Program (Need Help)
Author |
Message |
Daveliang99
|
Posted: Thu Feb 14, 2008 10:57 am Post subject: 649 Lottery Program (Need Help) |
|
|
Hey guys,
I'm currently stuck on this program trying to generate the lottery numbers to win the jackpot with my program.
Here are the instructions:
1. The user enters 6 Integer numbers between 1 and 49 then your program picks six random Integer numbers between 1 and 49.
2. Then compares your pick to the computers 6 picks. This continues and the program counts the number of attempts required until you hit the jackpot.
3. The program should output the final number of attempts.
Thanks for the help, i'd really appreciate it,
Dave Liang |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Thu Feb 14, 2008 3:16 pm Post subject: Re: 649 Lottery Program (Need Help) |
|
|
Use Rnd to produce a number in range [0, 1). Try to get numbers from 1 to 49 my doing some math. When you get a new number, make sure it is different from the ones you already have. |
|
|
|
|
![](images/spacer.gif) |
ericfourfour
|
Posted: Thu Feb 14, 2008 3:44 pm Post subject: RE:649 Lottery Program (Need Help) |
|
|
Just a suggestion, if you want as much help as possible, don't use a flashy signature. When I try to read your question, your signature distracts me. |
|
|
|
|
![](images/spacer.gif) |
syntax_error
![](http://compsci.ca/v3/uploads/user_avatars/196798963948cf16794b6e5.jpg)
|
Posted: Thu Feb 14, 2008 6:59 pm Post subject: RE:649 Lottery Program (Need Help) |
|
|
have you EVEN tried anything on your own?
btw I don't take your word for it; sorry. Not really; show some of your code so make sure you have even attempted it. |
|
|
|
|
![](images/spacer.gif) |
LaZ3R
|
Posted: Thu Feb 14, 2008 7:11 pm Post subject: RE:649 Lottery Program (Need Help) |
|
|
Show some code bud... I'm with syntax. The way you've worded your post made me think you have no code at all and simply want us to make it for you as "an example." |
|
|
|
|
![](images/spacer.gif) |
LaZ3R
|
Posted: Thu Feb 14, 2008 8:08 pm Post subject: RE:649 Lottery Program (Need Help) |
|
|
I made the program in 5 minutes... you do realize if you even understand the problem, that you will need a HELL OF A LOT OF ATTEMPTS before hitting all 6 numbers in a row.............
I'm not posting source, I'll only help if you post some of your own effort if you even made any. |
|
|
|
|
![](images/spacer.gif) |
Dr.Bokchoy
|
Posted: Sat Feb 16, 2008 11:58 am Post subject: Re: 649 Lottery Program (Need Help) |
|
|
wow, im from this guys class. dave, i cant believe im ur partner. well anyways, i need help on this too.
i was able to allow the user to input the 6 numbers and made the computer make its own six that didnt repeart but im wondering how it would compare it. I used a loop for making the numbers but whats the line that would get it out of the loop?
This is what i have so far
im wondering what i do to compare the numbers. when i tried it, the loop exited when just one of the numbers equaled the thing.
Quote: Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double, d As Double, e As Double, f As Double
Dim counter As Long
counter = 1
a = Text1.Text
b = Text2.Text
c = Text3.Text
d = Text4.Text
e = Text5.Text
f = Text6.Text
Dim a1 As Double, a2 As Double, a3 As Double, a4 As Double, a5 As Double, a6 As Double
'_________________
Do While a <> a1 And b <> a2 And c <> a3 And d <> a4 And e <> a5 And f <> a6
a1 = Str(Int(Rnd * 10) + 1)
a2 = Str(Int(Rnd * 10) + 1)
a3 = Str(Int(Rnd * 10) + 1)
a4 = Str(Int(Rnd * 10) + 1)
a5 = Str(Int(Rnd * 10) + 1)
a6 = Str(Int(Rnd * 10) + 1)
Do While (a1 = a2) Or (a1 = a3) Or (a1 = a4) Or (a1 = a5) Or (a1 = a6)
a1 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a2 = a1) Or (a2 = a3) Or (a2 = a4) Or (a2 = a5) Or (a2 = a6)
a2 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a3 = a1) Or (a3 = a2) Or (a1 = a4) Or (a3 = a5) Or (a3 = a6)
a3 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a4 = a1) Or (a4 = a2) Or (a1 = a3) Or (a4 = a5) Or (a4 = a6)
a4 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a5 = a1) Or (a5 = a2) Or (a1 = a3) Or (a5 = a4) Or (a5 = a6)
a5 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a6 = a1) Or (a6 = a2) Or (a1 = a3) Or (a6 = a4) Or (a6 = a5)
a6 = Str(Int(Rnd * 10) + 1)
Loop
counter = counter + 1
Label7.Caption = counter
Loop
End Sub |
|
|
|
|
![](images/spacer.gif) |
OneOffDriveByPoster
|
Posted: Sat Feb 16, 2008 6:34 pm Post subject: Re: 649 Lottery Program (Need Help) |
|
|
erm... is the "pick" supposed to be order-sensitive? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dr.Bokchoy
|
Posted: Sat Feb 16, 2008 8:06 pm Post subject: Re: 649 Lottery Program (Need Help) |
|
|
i dont think so and thats why it is making me have trouble with the exit of the loop |
|
|
|
|
![](images/spacer.gif) |
Dr.Bokchoy
|
Posted: Sat Feb 16, 2008 8:18 pm Post subject: Re: 649 Lottery Program (Need Help) |
|
|
hehe hi got it. stupid dave. lol, too focused on badminton.
Quote: Private Sub Command1_Click()
Dim a As Double, b As Double, c As Double, d As Double, e As Double, f As Double
Dim counter As Long
Dim answer As Double
counter = 1
a = Text1.Text
b = Text2.Text
c = Text3.Text
d = Text4.Text
e = Text5.Text
f = Text6.Text
Dim a1 As Double, a2 As Double, a3 As Double, a4 As Double, a5 As Double, a6 As Double
'_________________
Do While answer <> True
a1 = Str(Int(Rnd * 10) + 1)
a2 = Str(Int(Rnd * 10) + 1)
a3 = Str(Int(Rnd * 10) + 1)
a4 = Str(Int(Rnd * 10) + 1)
a5 = Str(Int(Rnd * 10) + 1)
a6 = Str(Int(Rnd * 10) + 1)
Do While (a1 = a2) Or (a1 = a3) Or (a1 = a4) Or (a1 = a5) Or (a1 = a6)
a1 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a2 = a1) Or (a2 = a3) Or (a2 = a4) Or (a2 = a5) Or (a2 = a6)
a2 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a3 = a1) Or (a3 = a2) Or (a1 = a4) Or (a3 = a5) Or (a3 = a6)
a3 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a4 = a1) Or (a4 = a2) Or (a1 = a3) Or (a4 = a5) Or (a4 = a6)
a4 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a5 = a1) Or (a5 = a2) Or (a1 = a3) Or (a5 = a4) Or (a5 = a6)
a5 = Str(Int(Rnd * 10) + 1)
Loop
Do While (a6 = a1) Or (a6 = a2) Or (a1 = a3) Or (a6 = a4) Or (a6 = a5)
a6 = Str(Int(Rnd * 10) + 1)
Loop
counter = counter + 1
Label7.Caption = counter
If a = a1 Or a = a2 Or a = a3 Or a = a4 Or a = a5 Or a = a6 Then
If b = a1 Or b = a2 Or b = a3 Or b = a4 Or b = a5 Or b = a6 Then
If c = a1 Or c = a2 Or c = a3 Or c = a4 Or c = a5 Or c = a6 Then
If d = a1 Or d = a2 Or d = a3 Or d = a4 Or d = a5 Or d = a6 Then
If e = a1 Or e = a2 Or e = a3 Or e = a4 Or e = a5 Or e = a6 Then
If f = a1 Or f = a2 Or f = a3 Or f = a4 Or f = a5 Or f = a6 Then
answer = True
End If
End If
End If
End If
End If
End If
Loop
Label1.Caption = a1
Label2.Caption = a2
Label3.Caption = a3
Label4.Caption = a4
Label5.Caption = a5
Label6.Caption = a6
End Sub
Private Sub Form_Load()
Randomize
End Sub
btw im not ur comp sci partner
the caption thing was just to check if it worked. |
|
|
|
|
![](images/spacer.gif) |
Daveliang99
|
Posted: Wed Feb 20, 2008 10:56 am Post subject: RE:649 Lottery Program (Need Help) |
|
|
thx for the help lol but ur counter is a bit messed up, oh well thats easy 2 fix. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Tue Apr 01, 2008 6:19 pm Post subject: Re: 649 Lottery Program (Need Help) |
|
|
This program's easy. All you need to do is make an array and a loop. You would need a nested for loop within another infinite do loop. The do loop will create random numbers and the for loop will check for repetitions. But you will have to put these 2 loops within another do loop which is the most outermost loop which will compare the 6 unique numbers to the 6 user numbers. |
|
|
|
|
![](images/spacer.gif) |
|
|