Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java In this exercise, you will first create a Student class. A Student has two attributes: name (String) and gradePointAverage (double). The class has
In Java
In this exercise, you will first create a Student class. A Student has two attributes: name (String) and gradePointAverage (double). The class has a constructor that sets the name and grade point average of the Student. It has appropriate get and set methods. As well, there is a toString method that prints the student's name and their grade point average (highest is 4.0) You will then write a demo program. In the demo program, you will create an ArrayList of Students. You will populate the arraylist with user inputted data. You should store the students alphabetically by name (A to Z) in the arraylist The algorithm to sort is simple. As you read in each name for the Student (say name1), compare it with each name (say name2 of a Student) stored in the arraylist starting from the index 0. As soon (name1.compareTo(name2) >0) that is the right index to put name1. Be sure that you do not cross the arraylist boundary In addition, you will write a method in your demo class that will take in your arraylist of students and return a new arraylist with the students sorted by their grade point average (highest to lowest). You can apply the same sort algorithm that vou used for the names. See below for a sample output. Enter student name or quit: Bush, Sue Enter grade point aye; 3.4 Enter student name or quit: Neddle, Ned Enter grade point ave; 3.2 Enter student name or quit: Zhang, Bin Enter grade point ave; 3.7 Enter student name or quit: Adda, Ida Enter grade point ave; 3.9 Enter student name or quit: quit Students [ Adda. Ida Grade Point Ave: 3.9, Bush, Sue Grade Point Ave: 3.4, Neddle. Ned Grade Point Ave: 3.2, Zhang, Bin Grade Point Ave: 3.7] Students in order of Grade Point Average [ Adda, Ida Grade Point Ave: 3.9Zhang, Bin Grade Point Ave: 3.7, Bush, Sue Grade Point Ave: 3.4, Neddle. Ned Grade Point Ave: 3.2]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