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...


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);
else
courses.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?



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here