Greetings everyone, I'm making a student Database utilizing an ArrayList Data Structure. The program works well for the most part except for when trying to add a student, a few things get really wonky. What I mean by wonky is that as soon as it prompts for a student ID, the program immediately follows it with a prompt for a netID and does not allow the user to input a value for both. The program also ends abruptly when prompting the student for gender. Here is the output:
Welcome to the UI Student Directory Database!
Please choose from the Choices below:
1. Add a Student
2. Remove a Student
3. Display Student Directory
4. Exit Database
---------------------------------------------
1
Please enter the first name of the Student:
Dan
Please enter the last name of the Student:
Steward
Please enter the major of the Student:
CE
Please enter the student's GPA:
3.2
Please enter the student's UIN:
Please enter the Student's netID:
876578
Please enter the Student's age:
30
Please enter the Student's gender:
---------------------------------------------
Welcome to the UI Student Directory Database!
Please choose from the Choices below:
1. Add a Student
2. Remove a Student
3. Display Student Directory
4. Exit Database
---------------------------------------------
m
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:864)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Lab3.main(Lab3.java:25)
Here is the actual code:
I don't see where I'm going wrong. I'm a bit flabbergasted. The addStudent method in the Lab3 class seems like it should work, but it behaves in a wonky fashion. Thanks!