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(); c++) 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 just exits and goes back to the menu. is there something wrong with my code?
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(); c++) 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 just exits and goes back to the menu. is there something wrong with my code?
Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter5: The Repetition Structure
Section: Chapter Questions
Problem 1MQ6: Write an Add method that adds the contents of the decPrice variable to the lstPrices control.
Related questions
Question
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(); c++)
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 just exits and goes back to the menu. is there something wrong with my code?
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning