Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Create a project in NetBeans and name the project Hw04. 2. Design and create a class that holds a student's first name, last name,
1. Create a project in NetBeans and name the project Hw04. 2. Design and create a class that holds a student's first name, last name, total earned credit hours, total quality points, and GPA. The definition of the class is given as follows: // default constructor public StudentRecord 0 \{ // ald code here to initialize data members of the class \} // constructor // paramters: nm: name, Eh: Earned credit hours, QPts: Total quality points public StudentRecord (string nm, int Eh, int QPts) \{ // add code here to initidize data members of the class \} // get the name of the student public string getName0 \{ // add code here \} // get earned hours public int getEarnedCho \{ // aul code here \} // get total quality points public int getQualPtso \{ // add code here \} // get GPA public double getGPAO \{ // add code here y // Change the student's name public void setName(string nm) \{ // add code here 3 // Change earned hours and update GPA public void setEarnedCh(int Eh) \{ // add code here // Change total quality points and update GPA public void setQualPts(int QPts)\{ // auld code here \} Give the implementations of the class constructors and member functions 3. Define the following interface and class public interface Sortinterface \{ / This method sorts the items of the StudentRecord array according to students' GPA in ascending order void sortGPA(StudentRecord v[], int n ); / is number of valid elements in the array \} public class Sort implements Sortinterface \{ public void sortGPA(StudentRecord v[], int n ) \{ I/ add code here ) / This method searches an item in a StudentRecord array v using a specific GPA. If a match found, the method returns the index of the item in the array. Otherwise, the method returns 1. You must. use binary search algorithm to implement the method (assume the array is sorted according to students' GPA). Parameter n is the number of valid elements in the array public int SearchGPA(SudentRecord v[], int n, double gpa) \{ // add code here \} \} 4. Write a test program that (1) Defines a StudentRecord array and necessary variables (2) Reads student's name, earned credit hours, and total quality points from keyboard, and stores them as an item (StudentRecord object) in the array (3) Repeat (2) for more items until user presses a specific key to stop it (4) Sorts the array by calling the method SortGPAO (5) Dienlav the iteme in the arrav accordino to the followino format. (6) Ask user for a GPA, and call the method SearchGPAO to search the array. If a match is found, i.e, there is an item with the target GPA in the array, display the information of item in the following format: (assume 2.00 is target GPA) Found a record: Name: Steven Liu Credit Hours: 30 QualityPoints: 60 GPA: 2.00 If no match is found, display No matched record
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