Results 1 to 3 of 3
Thread: Lottery Application
- 03-06-2012, 11:47 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 28
- Rep Power
- 0
Lottery Application
I am trying to write a lottery program which will read in six numbers and then check these numbers from a randomly generated draw but I cannot
get the numbers to output to my GUI correctly when I press a button to invoke the method I am getting the button I pressed but the other five output panels are coming up as zeros this is the method I have written
if anyone could point me in the direction where I am going wrong I would greatly appreciate it,if you need to see the full program let me knowJava Code:public void pickButton(int a){ int selection[]= new int[6]; int counter=0; for (int i = 0; i < 6; i++) { selection[counter]=a; for (int j = 0; j < i; ++j) { selection[counter] = a; } } choice1TextField.setText("" + selection[0]); choice2TextField.setText("" + selection[1]); choice3TextField.setText("" + selection[2]); choice4TextField.setText("" + selection[3]); choice5TextField.setText("" + selection[4]); choice6TextField.setText("" + selection[5]); counter++; }Last edited by Eranga; 03-06-2012 at 12:59 PM. Reason: code tags added
- 03-06-2012, 11:58 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,466
- Rep Power
- 16
Re: Lottery Application
Please use [code] tags [/code] when posting code.
What is this supposed to do?Java Code:int selection[]= new int[6]; int counter=0; for (int i = 0; i < 6; i++) { selection[counter]=a; for (int j = 0; j < i; ++j) { selection[counter] = a; } }
Because at the moment (since 'counter' never changes from 0) you are simply setting 'selection[0] = a' 30 odd times (give or take).Please do not ask for code as refusal often offends.
- 03-06-2012, 01:02 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Re: Lottery Application
You better take one step at a time. Seems your code segment not clear enough to others, including me. First you want to read six numbers, but how? We cannot see a clear way of doing that. Next generate random numbers and finally validate. Later on you can think about the UI stuff. So explain what you have tried in that code and we can comment on it.
BTW, if you want to know more about how to use code tags, please have a look at my forum signature. You can find a link there.
Similar Threads
-
Lottery Java Program please help
By grcarr77 in forum New To JavaReplies: 1Last Post: 10-16-2011, 07:20 PM -
Random Lottery Numbers
By ComicStix in forum New To JavaReplies: 2Last Post: 04-29-2011, 06:18 AM -
lottery
By kayln in forum EclipseReplies: 0Last Post: 02-20-2011, 09:28 PM -
Lottery help, looping problem
By hadoken5 in forum New To JavaReplies: 2Last Post: 10-31-2010, 06:48 PM -
Lottery Application
By notnumber6 in forum New To JavaReplies: 3Last Post: 11-03-2007, 11:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks