So I'm writing a program and part of it requires the user to input 5 track events, 4 team names, 6 athletes for each team, and what place every athlete got in each of the 5 events. In my code now, the program runs fine until the user has to input the second athlete name, and seems to skip the user input.
I have a feeling that there is a dangling white space somewhere and I tried placing input.next() in several places but it didn't fix the problem. Here is my code and a pic of the input error.
System.out.println("Please enter the 5 events in this competition.");
for(int i = 0; i < events.length; i++)
{
events[i] = input.nextLine();
}
for(int i = 0; i < teams.length; i++)
{
System.out.println("Please enter the name of team " + (i + 1));
teams[i] = input.nextLine();
for(int k = 0; k < athletes[i].length; k++)
{
System.out.println("Please enter the name of athlete " + (k + 1));
athletes[i][k] = input.nextLine();
for(int j = 0; j < places[i][k].length; j++)
{
System.out.println("What did " + athletes[i][k] + " place in " + events[j] + " ?");
places[i][k][j] = input.nextInt();
}
}
}