Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use java function as follow: In this assignment, you will create a Java program to create an array of students to search. The program must
Use java function as follow:
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 students 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 Student 2 GPA: 3.2 Student 3 name: Paul Brown Student 3 ID: 2201 Student 3 GPA:2.4 Student 4 name: Ice Frost Student 4 ID:4050 Student 4 GPA:1.2 Enter a student ID (enter to quit): 1004 Student name: Elsa Ice Student ID:1004 Student GPA:3.2 Enter a student ID (enter to quit): 2022 Student ID 2022 not found. Enter a student ID (enter to quit): 0 GoodbyeStep 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