Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this assignment, you will create a Java program to create an array of students to search. The program must implement a student class
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: float > +Student(String, int, float) +pringStudent(): void +getID(0: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 xx students!" where xx is the input number. 2. The program then prompts the user to input details of cach student including name, id, and gpa. 3. 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. 4. The main method will prompt user for each student. It then uses Student's constructor to create a Student object and assign it to an array element. 5. The Student class should have a constructor that takes a name, an id, and a gpa, to create a Student object. 6. The Student class should have a method printStudent() that prints the student's name, id, and gpa, one per line. 7. After the creation 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." 8. Since the student array may not be sorted, you should use linear search. 9. 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
Step by Step Solution
★★★★★
3.53 Rating (153 Votes )
There are 3 Steps involved in it
Step: 1
Student class package myPackage public class Student private String name private int id pr...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