Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I. Description In this assignment, you will create a Java program to create an array of students to search. The program must implement a student
I. Description In this assignment, you will create a Java program to create an array of students to search. The program must implement a student class as specified in the following UML diagram. Student -name: String -id: int -gpa: double > +Student > +Student(String, int, double) +pring Student():void +getID():int 1. The program will first ask the user to input the number of students to be created. The number should be from 1 to 10. Otherwise, the program prints "I cannot create xxx students!" where xxx is the input number. 2. You must create an array of Student in the main method. The size of the array is decided by the number of students the user gives. Each element of the array will refer to a Student object. 3. The program then prompts the user to input details of each student including name, id, and gpa. It then uses Student's constructor to create a Student object and assign it to an array element. 4. The Student class should have a constructor that takes a name, an id, and a gpa, to create a Student object. 5. The Student class should have a method printStudent() that prints the student's name, id, and gpa, one per line. 6. After the input of the Student objects, the program will then search the student array. It keeps asking the user for a student ID. If the student ID is 0, the program will print Goodbye!" and exit. Otherwise, the program will search the student array for the given student ID. If a match is found, the program will call printStudent() to print the student information. If no match is found, the program prints "Student ID xxxx not found." where xxxx is the ID given by the user. 7. Since the student array may not be sorted, you should use linear search. 8. A sample run will look like this where the green texts are user inputs: How many students do you have(1-10): 4 Student 1 name: Anna Stomp Student 1 ID:1002 Student 1 GPA: 2.3 Student 2 name: Elsa Ice Student 2 ID:1004 II. General Requirements Your program must include two Java files, one for the main class and the other for the Student class. Both classes must be in the same package. The package name should start with your last name, e.g., FuCIS265. Please name your main class file under your last name. For example, if your last name is "Fu", ", your file name should start with "Fu, e.g., FuAssignment2.java. You can assume that user inputs are the correct format. Exception handling is optional. The Scanner's nextInt() or nextDouble() method does NOT read the newline character. You need to call a nextLine() after nextInt() or nextDouble() to discard the newline character
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started