Question
Overloaded Sorting. In class, we have primarily used integer arrays as examples when demonstrating how to sort values. However, we can sort arrays made of
Overloaded Sorting. In class, we have primarily used integer arrays as examples when demonstrating how to sort values. However, we can sort arrays made of other primitive datatypes as well. You need three arrays of size 8; one array will be an integer array, one will be a char array, and one will be a float array. You will then ask the user to state what kind of data they want to sort - integers, chars, or floats. The user will then input 8 values. You will store them in the appropriate array based on what datatype they initially stated they would use. You will create a function called sortArray() that takes in an integer array as a parameter, and two overloaded versions of the same function that take in a char array and float array as parameters respectively. You will use these functions to sort the appropriate array and display the sorted values to the user. Note: You must make overloaded functions for this assignment - they must all be called sortArray(). You can not create unique, non-overloaded functions like sortArrayChars(). Sample Output #1: [Overloaded Sort] What data type do you want to enter? float Value 1: 3.4 Value 2: -1.0 Value 3: 2.0 Value 4: 10.3 Value 5: 90.2 Value 6: 8.4 Value 7: 8.6 Value 8: -2.3 Calling sortArray()... The sorted values are: -2.3, -1.0, 2.0, 3.4, 8.4, 8.6, 10.3, 90.2, Sample Output #1: [Overloaded Sort] What data type do you want to enter? char Value 1: a Value 2: c Value 3: f Value 4: b Value 5: e Value 6: z Value 7: x Value 8: y Calling sortArray()... The sorted values are: a, b, c, e, f, x, y, z
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import javautilArrays import javautilScanner public class OverloadedSorting Function to sort an inte...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started