Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA TEMPLATE: Main Class: public class MainClass { public static void main(String[] args){ Student studentArray[] = new Student[10]; //do{ System.out.println(User Menu:); System.out.println(Input Choice:); System.out.println(1. Insert

JAVA

image text in transcribed image text in transcribed

image text in transcribed

TEMPLATE:

Main Class:

public class MainClass {

public static void main(String[] args){ Student studentArray[] = new Student[10]; //do{ System.out.println("User Menu:"); System.out.println("Input Choice:"); System.out.println("1. Insert Student"); System.out.println("2. Delete Student by ID"); System.out.println("3. Search Student by ID"); System.out.println("4. Display All Students"); System.out.println("5. Exit"); //}while(/*User says exit*/) } }

Interface:

public interface StudentMethods { public void displayAll(); public void searchStudent(String id); }

Student Class:

public class Student {

private int ID; public void printInfo(Student a){ } }

Person Class:

public class Person { private String name; private int age;

}

From the given code template establish the relationships from the following class diagram. Person > Studentmethods - name: String - age: int + displayAll (): void + search Student (String id): void Student MainClass - ID: int ------- + studentArray (10): Student + printInfo (Student a): void Inherits Imported Implements Program Flow: Main Class implements the Interface Student Methods. When MainClass is executed, the following happens: 1. A user menu is displayed for the following: a. Insert Student b. Delete Student using ID C. Search Student using ID d. Display All Students e. Exit 2. All students are inserted into an array of Student Objects. 3. A Maximum of 10 students may be entered. 4. All information, Name, Age and ID must be user input (Hint: Use Scanner) 5. To delete a student, the user must input the ID of the student, search the array (excluding nulls) and display the object using Student->printinfo (Student a). 6. After displaying delete the student and replace the object in the array with Null 7. To Search for a Student, user must Input the ID of the student, search the array (excluding nulls) and display the object using Student->printInfo(Student a); This is the method searchStudent(String id) implemented from the Interface. 8. Search does not delete. 9. Display All students, executes the displayAll() method implemented from the Interface. All students in the studentArray must be displayed (excluding nulls). 10. Exit option closes the program. Error Handling: Handle the following errors: 1. If user enters an option from the menu that is not valid, display error to the User and repeat the menu. 2. No More than 10 students can be entered, if the array is full, display error message to the user and repeat the menu. 3. If ID already exists, display error message to User that the student cannot be created and repeat menu. If Search or Delete cannot find the student ID to display and delete, print error message to the User and repeat menu. Methods: Student class - printInfo (Student a): This method takes the input of the student object and prints the entire info of the student (Name, age and ID). Constraints: 1. All variables must have public Getters and Setters 2. Use Scanner for user Input. 3. All Classes must contain Constructors. ID: 1234 Name: Jane Age: 21 User Menu: Sample Output: User Menu: Input Choice: 1. Insert Student 2. Delete Student by ID 3. Search Student by ID 4. Display All Students 5. Exit Input Choice: 1. Insert Student 2. Delete Student by ID 3. Search Student by ID 4. Display All Students 5. Exit Insert Student ID: 1234 Insert Student Name: Jane Insert Student ID: 1237 Insert Student Age: 21 Insert Student Name: John Student Inserted! Insert Student Age: 21 Student Inserted! User Menu: Input Choice: 1. Insert Student 2. Delete Student by ID 3. Search Student by ID 4. Display All Students 5. Exit User Menu: Input Choice: 1. Insert Student 2. Delete Student by ID 3. Search Student by ID 4. Display All Students 5. Exit Insert Student ID to Delete: 1236 Student Not Found! ID: 1234 Name: Jane Age: 21 User Menu: Input Choice: ID: 1237 Name: John Age: 21 User Menu: Input Choice: 1. Insert Student 2. Delete Student by ID 3. Search Student by ID 4. Display All Students 5. Exit 6. Insert Student 7. Delete Student by ID 8. Se arch Student by ID 9. Display All Students 10. Exit Input Student ID to Search: 1234 5 Good Bye

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M Ricardo, Susan D Urban

3rd Edition

1284056945, 9781284056945

More Books

Students also viewed these Databases questions

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago

Question

6. Conduct a cost-benefit analysis for a training program.

Answered: 1 week ago