程序代写代做 algorithm Hive Java data structure CS526 Homework Assignment 3

CS526 Homework Assignment 3
Due: 2/11
This assignment has two parts.
Part 1
Part 1 is a practice of using Java’s LinkedList data structure.
In Assignment 2, your program read students’ grades from a text file and stored them in ArrayList. In this assignment, you will store them in a linked list. You must use Java’s LinkedList. The requirements are given below.
Write a program named Hw3_part1.java. You need to write all necessary methods within the program.
Your program must read from the input file and, for each student, calculate the average, determine the letter grade of the student (in the same way you did in Homework 2), and store all students’ grades information in a linked list. Then, print the following:
 Print all students’ grades in the same format as the one used in Homework 2.
 Print the information of the student who has the lowest average in the following format:
Jake: Average = 79.0, Grade = C+
 Print the information of the student who has the highest average in the following format: John: Average = 94.85, Grade = A
Part 2
Part 2 is a practice of implementing the insertion sort algorithm we discussed in the class. Name your program Hw3_part2.java.
First, you must convert the linked list you created in Part 1 to an array of student grades. The following is one simple way of converting your linked list to an array:
 Create an array of CourseGrade elements, whose capacity is the same as the size of the linked list.
 Copy the elements from the linked list to the array one at a time.
Second, you must write a method that sorts students in the array in increasing order of averages using the insertion sort algorithm we discussed in the class.

The signature of this sorting method must be:
public static void sortStudents(CourseGrade[ ] gradeArray)
This method receives an array of CourseGrade elements and sorts the array (or rearrange the elements in the array) in increasing order of averages.
You can use the insertion sort code in the textbook (Code Fragment 3.6, page 111) or the one in Slide 30 of Chapter 3 note with slight modification.
In the given code, elements are characters and they are directly compared. In this assignment, however, elements are students and you must compare averages of students.
In your main method, do the following to test your soring method:
 Read input file and add all student grade information to a linked list (this is what you did in Part 1 so you can use the same code).
 Convert the linked list to an array
 Print all elements in the array (this is before sorting)
 Sort the array by invoking your soring method
 Print all elements in the array again (this is after sorting)
If this is the input file:
John, 100, 100, 85, 96
Susan, 85, 90, 95, 72
Molly, 93, 90, 95, 92
Lindsey, 80, 100, 92, 75
Jake, 75, 80, 82, 80
Then, your output should be:
Before sorting:
Number of students is: 5
John: Average = 94.85, Grade = A
Susan: Average = 83.45, Grade = B
Molly: Average = 92.85, Grade = A‐
Lindsey: Average = 83.25, Grade = B
Jake: Average = 79.0, Grade = C+
After sorting:
Number of students is: 5
Jake: Average = 79.0, Grade = C+
Lindsey: Average = 83.25, Grade = B
Susan: Average = 83.45, Grade = B
Molly: Average = 92.85, Grade = A‐
John: Average = 94.85, Grade = A

Documentation
No separate documentation is needed. However, you must include sufficient inline comments within your program.
Deliverables
You need to submit Hw3_part1.java and Hw3_part2.java files. Combine these two files, and additional files if any, into a single archive file and name it LastName_FirstName_hw3.EXT, where EXT is an appropriate file extension, such as zip or rar. Upload this file to Blackboard.
Grading
Total points: 20
Part 1: Your program will be tested with two input files and up to 4 points will be deducted for each input file for which your output is wrong.
Part 2: Your program will be tested with two input files and up to 4 points will be deducted for each input file for which your output is wrong.
Up to 4 points will be deducted if there are not sufficient inline comments.