The goal of this assignment is to give you experience working with the Java Collection Framework and more familiarity with basic concepts of data structures. You will implement two different classes in one source file named Transform.java. Example inputs with their correct outputs are available.

Program Requirements

1. Create a non-public (and non-private) top-level class named Entry with instance variables for the last name, first name, course number, and semester values. You may choose whether to make your instance variables private, public, or default.

(a) You should declare a public Entry (String line) method which can construct the entry directly from a given line of input. This method can split the string by the separator and store the resulting fields in their respective instance variables. Hint: be sure to check out the String.split() method for parsing the entry.

(b) This class must implement the Comparable interface by overloading the public int compareTo(Entry other) method.

You must define a compareTo function that sorts the entries into ascending order by semester, then course, then last name, then first name. This means a.compareTo(b) should return a negative number when a should appear earlier than b.

(c) Overload the toString() method in order to print your processed entries according to the required format. Note that the format matches the order of the sort keys.

2. Create a public top-level named Transform (and put it and your Entry class from above into a source file named Transform.java). This class should contain your main method. Write your main method to create a Scanner and read the data from the user until the first blank, then read the filter course, then process the data.

Depending on your choice of data structure, you may or may not need to use Collections.sort() to sort by the required key sequence. If you create a List, you will have to sort it. If you create a TreeSet, it will sort automatically when you add to it.

Finally, you should iterate through the sorted elements of the collection and display those which pass the filter to standard out.

Example Transformation

Program Input

The data input format will consist of comma-separated tokens: lastName, firstName, semester, course. There will be one entry per line. There are no spaces between the values and the commas. A blank line will be entered to signify the end of the database. A final token will be issued to indicate the query (in this case, the query is 171).

Here is the example data:

Mcclaine,Kendria,F16,171
Windsor,Christalyn,S21,257
Widman-Pinheiro,Chantay,S20,171
Widman-Pinheiro,Chantay,S20,257
Hewlett-Claweson,Mahyar,F18,171
Hewlett-Claweson,Mahyar,F18,257
Hawkins,Desmund,F19,257
Hawkins,Desmund,F21,246
Yingling,Oswald,S18,257
Faulk,Joon,F16,257
Faulk,Joon,F16,246
Faulk,Joon,F16,171
Millan,Shekinah,F17,257
Millan,Shekinah,F17,246
Sallcup,Andriana,S16,257
Rodman,Jania,F16,246
Rodman,Jania,S20,171
Rodman,Jania,F20,257

171

Program Output

F16,171,Faulk,Joon
F16,171,Mcclaine,Kendria
F18,171,Hewlett-Claweson,Mahyar
S20,171,Rodman,Jania
S20,171,Widman-Pinheiro,Chantay
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.