Question: Program Planet Record Sorting Sorting is one of the most common applications of computer science. Java has built-in sorting methods that allow you to quickly



Program Planet Record Sorting Sorting is one of the most common applications of computer science. Java has built-in sorting methods that allow you to quickly and efficiently sort items in different ways. In this program, you will read in records from a file, sort them based on one of the fields of the records using Java's built-in sorting routines, and then write the sorted list to the console as a table. Things you will learn Creating simple classes Comparators and Java's sorting routines Reading input fromfiles and fomatting output. Specification In this assignment, you will implement a planet information sorter program. Your programmust include the following elements: 1. A class called "Planet" to hold a planet's information. 2. Different comparators to compare the different attributes of planets. Planet records will be specified in a file, one record per line. Each line of the file will have five comma-separted fields with no spaces between them (this is called a csv file). The fields will be planetName, yearDiscovered, mass. radius orbitPeriod, An example file is shown below: TrES 2006, 1 197, 1.247, 2.47 HAT-P-7b, 2008, l 781, 1.419,2.204 Kepler-4b, 2010, 0.077, 0.357, 3.213 The program must take two pieces of input, either as command line arguments, or by prompting the user for input: 1. the name of a file containing planet records. 2. the name of a field (attribute) of the records on which to sort, which must be one of planetName, yearDiscovered, mass, radius, orbitPeriod
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
