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

Username:   Password: 
 RegisterRegister   
 649 Lottery Program (Need Help)
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Daveliang99




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




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




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




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




PostPosted: 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."
LaZ3R




PostPosted: 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.
Dr.Bokchoy




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




PostPosted: Sat Feb 16, 2008 6:34 pm   Post subject: Re: 649 Lottery Program (Need Help)

erm... is the "pick" supposed to be order-sensitive?
Sponsor
Sponsor
Sponsor
sponsor
Dr.Bokchoy




PostPosted: 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
Dr.Bokchoy




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




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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: