1 CIS 265 Data Structures and Algorithms Assignment 6, 100 points Due: 12:24pm, Thur, Mar. 18, 2021 I. General Description In this assignment, you will create a Java program to read undergraduate and...

attached .


1 CIS 265 Data Structures and Algorithms Assignment 6, 100 points Due: 12:24pm, Thur, Mar. 18, 2021 I. General Description In this assignment, you will create a Java program to read undergraduate and graduate students from an input file, sort them, and write them to an output file. This assignment is a follow up of assignment 5. Like assignment 5, your program will read from an input file and write to an output file. The input file name and the output file name are passed in as the first and second arguments at command line, respectively. Unlike assignment 5, the Student objects are sorted before they are written to the output file. • The program must implement a main class, three student classes (Student, UndergradStudent, GradStudent), and a Comparator class called StudentIDComparator. • The StudentIDComparator class must implement the java.util.Comparator interface, and override the compare() method. Since the Comparator interface is a generic interface, you must specify Student as the type parameter when defining the StudentIDComparator class, i.e., public class StudentIDComparator implements Comparator { • The signature of the compare method should be public int compare(Student s1, Student s2). The compare() method returns a negative, 0, or positive integer if s1 is less than, equals, or is greater than s2, respectively. • To sort the ArrayList, you need to create a StudentIDComparator object and use it in the Collections’ sort method: StudentIDComparator idSorter = new StudentIDComparator(); Collections.sort(students, idSorter); //students is an arrayList of Students II. Submission This is an individual assignment. Each student needs to submit the source code files of the Java program on Blackboard. 1. Put all you Java files in a folder. Please name the folder after your package name, for example, FuAssign6. Compress the folder into a .zip file and submit the .zip file. 2. You need to only submit the source code, i.e., the Java files. 3. You may submit multiple time. Your most recent submission before the deadline will be graded. III. Grading 1. A program that does not run will receive 0 point. 2. There is a 10-20 points deduction for each major error, e.g., missing a student in the output. 3. There is a 1-9 points deduction for each minor error, e.g., a spelling error in printed message. 4. A program that does not follow the guidelines will lose 1-10 points. 5. Any type of cheating is not tolerated. You may be asked to explain your program in person. 2 IV. Bonus features (optional) You may implement as many bonus features as you want. If you implement any bonus feature in your program, please put a comment in your Blackboard submission and in your main Java file. In your comments, explain which bonus feature(s) you implemented. 1. (10 points) Your program will ask the user which data field is used to sort the students, name, ID, or gpa. It will then sort the students accordingly and write the sorted list to an output file provided at command line. Your program should ignore invalid values and prompt again. A sample run may look like this: Which field should be used to sort Students(1-3): 1. Name 2. ID 3. GPA 0 Which field should be used to sort Students(1-3): 1. Name 2. ID 3. GPA 4 Which field should be used to sort Students(1-3): 1. Name 2. ID 3. GPA 1
Mar 11, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here