I was doing the love tester program for my assignment. Then, I've encounted some problems after I run the program.
Here is my code:
public class SEAN_LAB3
{
public static void main(String[] args)
{
int i;
String [] bName = new String [5];
String [] gName = new String [5];
char choice;
System.out.println("*****************************************************");
System.out.println("This program is used to randomly match boys and girls");
System.out.println("*****************************************************\n");
System.out.println("Please enter the names of 5 boys:");
for (i=0; i<bName.length; i++)
{
bName[i] = scan.next();
}
System.out.println("Please enter the names of 5 girls:");
for (i=0; i<gName.length; i++)
{
gName[i] = scan.next();
}
do
{
System.out.println("The result of the matching:");
for (i=0; i<5; i++)
{
System.out.println(bName[(int)Math.random()*5] +" and "+ gName[(int)Math.random()*5]);
}
System.out.print("Do you want to re-match? (y/n): ");
choice = charAt(0);
} while (choice == 'y');
System.out.println("Thank you for using the program.");
}
}