Hello guys,
I have created a basic working java lottery application, it predicts 5 numbers and a bonus ball, all working and a great first Java project. However, it will repeat intergers, so i need to add a bit to the code so if a ball has already been picked it wont be picked again....
Here is the code so far:
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class LoteryApp extends Object
{
public static void main(String[] argStrings) throws Exception
{
Random random = new Random();
int[] lotteryNumbers = new int[5];
int bonusBall = random.nextInt(49);
for (int index = 0; index < lotteryNumbers.length; index = index + 1)
{
lotteryNumbers[index] = random.nextInt(49);
}
System.out.println("Your lucky numbers are:");
for (int index = 0; index < lotteryNumbers.length; index = index + 1)
{
System.out.println(lotteryNumbers[index]);
}
System.out.println("Your Bonus Ball is:");
System.out.println(bonusBall);
}
}
You have a great forums here, thanks for helping.
Joel