void removeStudent(){System.out.print("\n Enter StudentID to remove: ");long id =sc.nextLong();int pos = searchStudentID(id);if(pos == -1)System.out.println("\n ERROR: No student found having same ID: " + id);elsecourses.remove(pos);}
int searchStudentID(long studentID){for(int c = 0; c < students.size();="">if(studentID == students.get(c).getId())return c;return -1;}
The code is supposed to prompt the user to enter a studentID and if it is in the records then it will be removed, but instead it just prompts me to enter and when i enter the ID, it does not remove the ID (I display the data again after I supposedly removed it but it is still there) and just returns back to the menu. What can I do to correct it?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here