Who are the experts?Experts are tested by 4476mountvernon.com as specialists in their subject area. We review their content and use your feedback to keep the quality high.

You are watching: Cannot invoke compareto(int) on the primitive type int

1. Error occurs is "cannot invoke compareTo() on primitive type int" because since int is a pimitive type it does not have have any methods,only objects does. 2. to overcome this pr…View the full answer

See more: Is First Grade Capitalized, How To Write Grade Numbers In Apa Style

Transcribed image text: 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.