0

this is probably pretty simple, but I can't figure it out. I just have a simple series of keyboard inputs with a prompt string in front of them, and for some reason, it just decides to skip one. Code:

            System.out.println("Enter student ID");
            int i = input.nextInt();

            System.out.println("Enter Last Name");
            String l = input.nextLine();

            System.out.println("Enter First Name");
            String f = input.nextLine();

            System.out.println("Enter major");
            String m = input.nextLine();

            System.out.println("Enter GPA");
            Double g = input.nextDouble();

            System.out.println("Inserted student record");
            StudentBST.insert(i, l, f, m, g);

When I run it though, it just straight up skips over the Last Name entry, and moves on to First Name. The run output looks like this.

Enter student ID
3
Enter Last Name
Enter First Name
ellen
Enter major
art
Enter GPA
3.4

Right there, just skips entering Last Name. Any ideas as to why?

user3066571
  • 1,177
  • 3
  • 13
  • 29

0 Answers0