Question: Main Method: import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; public class Assginment { public static void main(String[] args)

![main(String[] args) throws FileNotFoundException, IOException { FileReader f = new FileReader(args[0]); BufferedReader](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3066d64e05_92466f3066cc4979.jpg)

Main Method:
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; public class Assginment { public static void main(String[] args) throws FileNotFoundException, IOException { FileReader f = new FileReader(args[0]); BufferedReader b = new BufferedReader(f); String line = ""; ArrayList
Btw please don't forget, Run Argument: students.txt students_reversed.txt
Thank you so much!
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 concrete type. The signature of the compare method be public int compare(Student sl, Student s2). The compare() method returns a negative, 0, or positive value if sl is less than, equals, or is greater than s2, respectively. To sort the ArrayList, you need to create a Student IDComparator object and use it in the Collections' sort method: Student IDComparator idSorter = new Student IDComparator(); Collections. sort(students, idSorter); //students is an arrayList of Students 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. (15 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. A sample run may look like this: Which field should be used to sort Students (1-3): 1. Name 2. ID 3. GPA Which field should be used to sort Students (1-3): 1. Name 2. ID 3. GPA Which field should be used to sort Students (1-3): 1. Name 2. ID 3. GPA The UML class diagram should be as follows. Student -name: String -id: int -gpa: float +Student +Student(name,id, gpa) +pring Student():void +getID:int +printStudent (Print Writer output:void UndegradStudent -boolean: is Transfer +UndergradStudent(name,id, gpa, is Transfer) +pring Student:void #printStudent(Print Writer output):void GradStudent -college:String +GradStudent(name,id, gpa.college) +pring Student():void +printStudent Print Writer output):void students.txt James Bond, 200304,3.2, undergraduate, true Michelle Chang, 200224,3.3, graduate, cleveland State University Tayer Smoke, 249843,2.4, undergraduate, false David Jones, 265334, 2.7, undergraduate, true Abby Wasch, 294830,3.6, graduate, West Virginia Nancy Drew, 244833,2.9, graduate, Case Western Lady Gaga, 230940,3.1, undergraduate, false Sam Jackson, 215443,3.9, graduate, Ohio State University
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
