How to generate multiple set of Lotto numbers?
I created this lotto program to pick unique random numbers. It works succesfully. I now want to have command line where the user will input how many set of lotto number they want. Let say 3, so the output should show something like this:
(A) 23 21 01 07 08 06
(B) 22 34 11 30 34 21
(C)14 1247 33 24 01
Do I use the loop?. Can anyone help me?. So far I am only able to generate one set, the Alpha character will also have to go from A-Z then back to A. Any help will be appreciated.
[513 byte] By [
aivon1sta] at [2007-11-27 9:41:55]

Yes, just create a loop to call whichever method generates the numbers. If you are having trouble then post some code.
Does the loop need to be generated inside the method?. I have a method called 'genLottoNum(int num)'. So, if the user entered 3, to call this method I would do:
int luckyNumbers;
luckyNumbers = genLottoNum(3);
Do I do this right?...sorry if this is a silly questions. I'm kinda lost in Java. :(
> ...> Do I do this right?...Yes, you do.
When the user enter the number, the data type is a string.
I tried to convert this to Integer but kept getting error. Where do I need to insert this code conversion:
args = Integer.parseInt(args);
Is this correct?
This is my code:
public class LottoMachine
{
public static void main(String args[])
{
new Lotto(args);
}
class Lotto
{
int luckyNumbers;
Lotto (String args[])
{
if(args = 0)
{
System.err.println("Usage: java Lotto # of Lotto ticket you want");
System.exit();
}
if(args > 0)
luckyNumbers = genLottoNumbe(args);
}
Shouldn't luckyNumbers be an array of int's? And this makes no sense:if(args = 0)
But before continuing, I think it's a really, really good idea if you read this basic tutorial on how to work with arrays:
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
You'll want to bookmark this:
http://java.sun.com/javase/6/docs/api/
Take a look at the API for parseInt:
http://java.sun.com/javase/6/docs/api/java/lang/Integer.html#parseInt(java.lang.String)
variable args is of type String[ ]. Method parseInt doesn't take an *array* of Strings, does it?
I've been searching and reading lots of information from the site you guys provided, but my assignment is due tomorrow, any help will be appreciated.
I don't think you understand arrays well enough, do you? http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
> I've been searching and reading lots of information> from the site you guys provided, but my assignment> is due tomorrow, any help will be appreciated.Ok, then you only need to read the link from reply #5 or #8.
I'm taking summer class and work fulltime. It is very hard to grasps the information that teacher gives with lack of exercises. We have daily class and just when I thought I'm starting to understand the concept, I started to get confused again. Do you have any advice on how I can get up to speed?. It does not help when the teacher keep jumping from one chapter to another. Thanks for your help.
> ... > Do you have any advice on how I can get up to speed?. > ...Like I already suggested: read the tutorial about arrays.