I am working on writing a for loop that will keep track of players on a team. First, the loop asks how many players, then you add in the info.
The first iteration is completely skipping the player name and I can't figure out why when the remaining iterations collect the player name correctly.
Code:
System.out.print("Enter the number of players on your team: ");
int n = s.nextInt();
for(int i = 1; i <= n; i++) {
System.out.println("Player's name: ");
name = s.nextLine();
System.out.println("Player's position: ");
position = s.nextLine();
System.out.println("Player's jersey number: ");
number = s.nextLine();
}
Result: