in C++ language Create an object-oriented program that uses a sorting algorithm to implement the following functionality:
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 simplicity’s 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
I've updated the answer and yeah I've used Bubble Sort!
The loops j,k are doing the bubble sort!
Code:-
#include <iostream>
using namespace std;
int main()
{
int n=25,i=0;
int arr[n],x;
while(n)
{
cout<<"Enter number "<<i+1<<"(-1 to end):
";
cin>>x;
if(x!=-1)
arr[i++]=x;
else
break;
n--;
}
int k,j,temp;
for(k=0;k<i;k++)
{
for(j=0;j<i-1;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
n=i;
float y;
cout<<"The averages of your values are: \n";
for(i=0;i<(n/2);i++)
{
x=arr[i]+arr[n-i-1];
y=(float)x/2;
cout<<y<<" ";
}
return 0;
}
Output:

in C++ language Create an object-oriented program that uses a sorting algorithm to implement the following...
PLEASE DO THIS IN C#.Design and implement a program (name it ProcessGrades) that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below. Sample run 1: You entered: 95, 80, 100, 70 Highest grade: 100 Lowest grade: 70 Average grade: 86.25
use
C++ programming language and follow the instruction carefully.
thanks!
Inputs: . [integer] values (10 times) Outputs: • [integer) highest value . [integer] lowest value Description: Write a program that lets the user enter 10 values. These values should be stored in an array. Your program will then find the highest and lowest values in the array. Your program will display the list of number as a comma separated list, and print which values is the highest and lowest Do...
Problem statement For this program, you are to implement a simple machine-learning algorithm that uses a rule-based classifier to predict whether or not a particular patient has diabetes. In order to do so, you will need to first train your program, using a provided data set, to recognize a disease. Once a program is capable of doing it, you will run it on new data sets and predict the existence or absence of a disease. While solving this problem, you...
Write a program in Java language to prompt the user to enter 3 integers (A, B, and C) then display these numbers from the lowest to the highest (sorted ascendingly) . Note that there are 6 different cases to handle proper order. As an example, a user entered 10 for A, 5 for B and 14 for C: the output of the program should look like this Enter number A? 10 Enter number B? 5 Enter number C? 14 Your...
Write an object-oriented C++ program (i.e. a class and a main function to use it), using pointer variables, that program that performs specific searching and sorting exercises of an array of integers. This program has six required outputs. Start by initializing an array with the following integers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Your array input may be hardcoded...
c++ language Write a program that contains the following functions, i. A function isVowel that takes in a character and returns true if it is a vowel and false otherwise ii. A function that request from the user to enter in a sequence of characters, and outputs the number of vowels entered. (Use Function in a) to assist you, a sentinel value can be used to specify the end of the user input iii. A function that reads 3 test...
In C++
2. Write a program that allows the user to enter a series of positive numbers between 1 and 100 and displays the smallest and largest of the numbers entered. The program should not store the numbers that were entered, only keep track of the smallest and largest ones. The program should continue accepting numbers until the value 0 is entered and then display the results. If a number out of range is entered, tell the user it is...
In Java Programming: Create a flow chart for a program that prompts for an integer N (number of students) and M (number of test scores for each students), and allows the user to N*M real numbers. The program then calculates the average for each student and class average. (1) Prompt the user to input N students and M test scores, then display the inputs. Enter number of students: You entered: 2 Enter number of test scores: You entered: 3 Enter...
In the Java language
APCS Sorting Numbers Lab Write a program that reads in 3 floating-point numbers (decimal numbers) and prints the three numbers in sorted order from smallest to largest. In your main method, create a scanner and get the 3 numbers from the user. Create a separate method called sort that accepts the 3 numbers prints them in the appropriate order. Sample Run#1 Please enter first number: 4 Please enter second number: 9 Please enter third number: 2.5...
Language is C++ NOTE: No arrays should be used to solve problems and No non-constants global variables should be used. PART B: (Statistics Program) – (50%) Please read this lab exercise thoroughly, before attempting to write the program. Write a program that reads the pairs of group number and student count from the text file (user must enter name of file) and: Displays the number of groups in the file (5 %) Displays the number of even and odd student...