Modify your assignment submission code to answer the following questions 1 Create an interface

Modify your assignment submission code to answer the following questions: 1. Create an interface StudentModel for the student model to store student data you wish to keep unchanged such as studentID and StudentEmail. Modify the existing Student class to implement StudentModel and convert it to an abstract class with the reportReport and deleteStudent as the abstract methods. 2. Consider the following two implementation options for student search for Array and ArrayList respectively. Implement a search without a for loop, you may use methods within the two data structures to optimize the code. public void searchStudent(String searchID) { int foundIndex = findStudentByID(searchID); if (foundIndex != -1) { System.out.println("Student found:"); System.out.println("Student ID: " + studentIDs[foundIndex]); System.out.println("Student Name: " + studentNames[foundIndex]); System.out.println("Student Email: " + studentEmails[foundIndex]); System.out.println("Student Course: " + studentCourses[foundIndex]); } else { System.out.println("Student with student ID " + searchID + " was not found."); } } private int findStudentByID(String searchID) { for (int i = 0; i < studentCount; i++) { if (studentIDs[i].equals(searchID)) { return i; } } return -1; }

Modify your assignment submission code to answer the following questions:

1. Create an interface StudentModel for the student model to store student data you wish to keep unchanged such as studentID and StudentEmail. Modify the existing Student class to implement StudentModel and convert it to an abstract class with the reportReport and deleteStudent as the abstract methods.

2. Consider the following two implementation options for student search for Array and ArrayList respectively. Implement a search without a for loop, you may use methods within the two data structures to optimize the code.

public void searchStudent(String searchID)
{
int foundIndex = findStudentByID(searchID);

if (foundIndex != -1)
{
System.out.println(“Student found:”);
System.out.println(“Student ID: ” + studentIDs[foundIndex]);
System.out.println(“Student Name: ” + studentNames[foundIndex]);
System.out.println(“Student Email: ” + studentEmails[foundIndex]);
System.out.println(“Student Course: ” + studentCourses[foundIndex]);
}
else
{
System.out.println(“Student with student ID ” + searchID + ” was not found.”);
}
}

private int findStudentByID(String searchID)
{
for (int i = 0; i < studentCount; i++) { if (studentIDs[i].equals(searchID)) { return i; } } return -1; }


 
Solved By Verified
Study Co-Pilot All Study Co-Pilots are evaluated by Gotit Pro as an expert in their subject area.

 
Instant
Download

Student review: (5 ratings) 5 out of 5 people found this solution helpful.