So I'm extremely rusty with my java programming. I'm trying to create a hypothetical company lottery where each employee can only enter once. Then a name will be randomly generated announcing the winner. I'm not even sure I have some things in the right order at the moment. Any help on this will be greatly appreciated. I looked up some things and I believe it to have made it worse.
// instance variables
final int NUM_PARTIC = 7; // number of workers participating
String input; // holds each name
int i, j;
// Create array to hold number of particpants.
String[] nameArray = new String[NUM_PARTIC];
// Create a Random class object.
Random stakes = new Random();
for(i = 0; i < nameArray.length; i++)
{
// Prompt participant for name.
input = JOptionPane.showInputDialog(null, "Please enter your"
+ " name into our database:", "Entry", JOptionPane.QUESTION_MESSAGE);
nameArray[i] = input; // Store name in namesArray[]
// Prompt next participant for name
input = JOptionPane.showInputDialog(null, "Please enter your name into our"
+ " database:", "Entry", JOptionPane.QUESTION_MESSAGE);
nameArray[i] = input; // Store name in namesArray[]
for(j = i + 1; j < nameArray.length; ++j)
{
JOptionPane.showMessageDialog(null, "Sorry, this name is already "
+ "in our database", "Invalid", JOptionPane.ERROR_MESSAGE);
input = JOptionPane.showInputDialog(null, "Please enter your name into our"
+ " database:", "Entry", JOptionPane.QUESTION_MESSAGE);
}
// Display winner
JOptionPane.showMessageDialog(null, "The winner for today's raffle "
+ "is: " + nameArray[i], "Winner",
JOptionPane.WARNING_MESSAGE);
// Exit program
System.exit(0);