Question: The file Sorting.java contains the Sorting class from lecture slides. This class implements both the selection sort and the insertion sort algorithms for sorting any

 The file Sorting.java contains the Sorting class from lecture slides. Thisclass implements both the selection sort and the insertion sort algorithms forsorting any array of Comparable objects in ascending order. In this exercise,you will use the Sorting class to sort several different types ofobjects l. The file Numbers.java reads in an array of integers, invokesthe selection sort algorithm to sort them, and then prints the sortedarray. Save Sortingjava and Numbersjava to your directory. Numbersjava won't compile inits current form. Study it to see if you can figure out

The file Sorting.java contains the Sorting class from lecture slides. This class implements both the selection sort and the insertion sort algorithms for sorting any array of Comparable objects in ascending order. In this exercise, you will use the Sorting class to sort several different types of objects l. The file Numbers.java reads in an array of integers, invokes the selection sort algorithm to sort them, and then prints the sorted array. Save Sortingjava and Numbersjava to your directory. Numbersjava won't compile in its current form. Study it to see if you can figure out why. Hint: Wrapper class of int 2. Try to compile Numbers,java and see what the error message is. The problem involves the difference between primitive data and objects. Change the program so it will work correctly (note: you don't need to make many changes the autoboxing feature of Java 1.5 will take care of most conversions from int to Integer when scan in data from keyboard) 3. Write a program Strings,java, similar to Numbers.java, that reads in an array of String objects and sorts them. You may just copy and edit Numbers.java. 4. Modify the insertionSort algorithm so that it sorts in descending order rather than ascending order. Change Numbersjava and Stringsjava to call insertionsort rather than selectionsort. Run both to make sure the sorting is correct. 5. The file Salespersonjava partially defines a class that represents a sales person. This is very similar to the Contact class in our lecture. However, a sales person has a first name, last name, and a total number of sales (an int) rather than a first name, last name, and phone number. Complete the compareTo method in the Salesperson class. The comparison should be based on total sales; that is return a negative number if the executing object has total sales less than the other object and return a positive number if the sales are greater. Use the name of the sales person to break a tie (alphabetical order 6. The file Weekly Sales java contains a driver for testing the compareTo method and the sorting Compile and run it. Make sure your compare To method is correct. The sales staff should be listed in order of sales from most to least with the four people having the same number of sales in reverse alphabetical order. 7. OPTIONAL: Modify WeeklySalesjava so the salespeople are read in rather than hardcoded in the 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!