Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use java it will looks like following format: Use student.txt, that contain following info: [ 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

Use java

it will looks like following format:

image text in transcribed

image text in transcribed

Use student.txt, that contain following info:

[

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

]

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

image text in transcribed

C: Intel Logs PanoptoRecorder PerfLogs Program Files Program Files (x86) qycache Users Windows import java.io.File; import java.util.collections; import java.util.Comparator; import java.io.IOException; import java.io.Printwriter; import java.util.ArrayList; import java.util.Scanner; public class FuAssignment6 { G FuAssignment6.java Compile Messages JGRASP Messages Run! Open Projects ED Stop Clear Copy FuAssign6 C:\Users\Yong OneDrive Documents\CIS A Source Files FuAssignment.java FuAssign6 J GradStudent.java FuAssignol Student.java FuAssign StudentGPAComparator.java FuAssignl StudentID Comparator.java FuAssign6l J StudentNameComparator.java FuAssignol J UndergradStudent.java FuAssign61 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, Undergrad Student, Grad Student), and a Comparator class called Student IDComparator. The StudentID Comparator 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 StudentID Comparator class, i.e., public class Student IDComparator implements Comparator_{ The signature of the compare method should be public int compare(Student sl, Student s2). The compare() method returns a negative, 0, or positive integer if sl is less than, equals, or is greater than s2, respectively. To sort the ArrayList, you need to create a Student ID Comparator 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 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Compare the current team to the ideal team.

Answered: 1 week ago

Question

a. Do team members trust each other?

Answered: 1 week ago