Alright so I am still kinda new to java
I am working on a lottery program that will ask the user how many tickets they would like (default being five) and each ticket has a random set of numbers plus a jackpot number:
this is the code have so far...
import javax.swing.JOptionPane;
import java.util.Arrays;
public class LuckyNumbers
{
public static void main(String[] args)
{
// number of lucky numbers
// number of elements for the lucky numbers
final int LUCKY_NUMBERS = 5;
int[] luckyNumbers = new int[LUCKY_NUMBERS];
// generate five random numbers
for (int i = 0; i < luckyNumbers.length; i++)
{
luckyNumbers[i] = (int) (Math.random() * 56) + 1;
}
Arrays.sort(luckyNumbers); // sort the elements
int goldenNumber = (int) (Math.random() * 46) + 1; // draw the golden number
// print the numbers
JOptionPane.showMessageDialog(null, "Your Lucky Numbers arrrrre....\n*drumroll*\n\n" + "Ticket 1:\n" + Arrays.toString(luckyNumbers) + "Golden Number:" + goldenNumber, "WELCOME TO THE LOTTERY!",
JOptionPane.INFORMATION_MESSAGE);
}
}