Question: Can you answer the following question in Java, Please? This Program lets you read data from a file then sort it by two different methods.

Can you answer the following question in Java, Please?
This Program lets you read data from a file then sort it by two different methods. One is the built-in sort() method, and the other will be your own method that implements a mergeSort algorithm. You will compare the performance of the two implementations.
This program builds a set of classes to sort a linked list of objects in multiple ways and compare the execution time of each type of sort.
Directions -Write a class 'WeatherReport', that has the following methods:
1. Constructor with no parameters. It should create a linked list of 8-10 'Temperature' objects which you can use for testing. Each 'Temperature' object should have a City, State, Low Temperature and High Temperature, along with a method 'Differential', that returns the positive difference between the low and high temperature for that object. Dont include any other attributes in your 'Temperature' object.
2. Constructor with one String parameter the name of a text file with weather information. The file has a header row, then many rows of temperature recordings.
For example:
Average,City,Code,Direction,Full,Maximum,Minimum,Month,Precipitation,WindSpeed,State,Day,Year
39,Birmingham,BHM,33,1/3/2016,46,32,1,0,4.33,Alabama,3,2016
39,Huntsville,HSV,32,1/3/2016,47,31,1,0,3.86,Alabama,3,2016
This constructor will create a linked list of 'Temperature' objects, one for each row of data in the file. Your project will have the data file weather.txt Download 'weather.txt' which you should use for the program.
3. isSortedByCity() this boolean method returns true if the linked list is in sorted order by city, and false otherwise. Calling this method on the list generated by the constructor should return false.
4. isSortedByHigh() this boolean method returns true if the linked list is in sorted order by highest temperature, and false otherwise. Calling this method on the list generated by the constructor should return false.
5. sortWithCollections(String by) sorts the linked list using Collections.sort(). The parameter by tells you whether it should be by City or by high temperature.
sortWithMerge(String by) sorts the linked list using your own merge sort implementation. The parameter by tells you whether it should be by City or by high temperature.
7. main test your class by writing a main method that creates 4 'WeatherReport' objects with exactly the same data, and tests each to be sure it is not already sorted. Sort one by calling 'sortWithCollections(City) 'and the other by calling 'sortWithMerge(City)'. Be sure to time the results of each sort and record the times. Repeat this for sorting by high temperature. Be sure the linked lists really are sorted.
 Can you answer the following question in Java, Please? This Program

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!