Question
Create an object-oriented program that uses a sorting algorithm to implement the following functionality: The program prompts you to enter a series of numbers (up
Create an object-oriented program that uses a sorting algorithm to implement the following functionality:
The program prompts you to enter a series of numbers (up to a maximum of 24, so you can use a static array) with -1 as an end code.
When the program encounters a -1, it does not insert the -1, instead, it outputs a list of half the original size, consisting of the averages of the highest and lowest pairs of numbers from beginning to end.
For example, if the list you enter is 1, 5, 3, 10, 19 and 8, the result would be 10, 6.5, 6.5
That is, the average of 1 and 19 (highest and lowest values) = 10, the average of 3 and 10 (second-highest and second-lowest values) = 6.5, and then the average of 5 and 8 (third-highest and third-lowest values) = 6.5. For simplicitys sake you can assume that the user will always enter an EVEN number of values. I will not use an odd sequence in evaluating your program.
Sample Output
This program reads in a series of up to 25 numbers
and outputs the averages of the values in MIN/MAX pairs.
Enter number 1 (-1 to end): 30
Enter number 2 (-1 to end): 6
Enter number 3 (-1 to end): 7
Enter number 4 (-1 to end): 2
Enter number 5 (-1 to end): 50
Enter number 6 (-1 to end): 16
Enter number 7 (-1 to end): 8
Enter number 8 (-1 to end): 5
Enter number 9 (-1 to end): 99
Enter number 10 (-1 to end): 3
Enter number 11 (-1 to end): -1
The averages of your values are: 50.5 26.5 17.5 11 7.5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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