Im working on an issue where i need a program to randomly generate numbers and not repeats them. I also need the progam to ask for the users input:
"How many lotto lines do you want to generate"??
So when the user put in 5 - the user gets 5 lines of lotto code
The code i have so far is :
import java.util.ArrayList;
import java.util.Random;
package javaapplication2;
/**
*
* @author Stirbob
*/
public class loto {
public static void main(String[] arg) {
ArrayList<Integer> al = new ArrayList<Integer>();
for(int r = 1; r <= 42; r++)
al.add(r);
Random ran = new Random();
for(int r = 0; r < 6; r++) {
int n = al.remove(ran.nextInt(al.size()));
System.out.print(" " + n);
}
System.out.println();
}
}
Please Help??
This post has been edited by macosxnerd101: 19 November 2010 - 09:06 AM
Reason for edit:: Please use code tags.

New Topic/Question
Reply




MultiQuote






|