Homework Solution: Develop a program that calculates basic statistics on a one-dimensional array of doubles. Your…

    C++ Assignment Description: Develop a program that calculates basic statistics on a one-dimensional array of doubles. Your program should first prompt the user for the size of the array followed by prompting for individual elements of the array. Your program should contain the following functions: 1.) min() Finds and returns the minimum value within the array. 2.) max() Finds and returns the maximum value within the array. 3.) mean() Finds and returns the mean value of the elements in the array. 4.) median() Finds and returns the median value of the elements in the array. 5.) sort()* Sorts the elements of the array in ascending order. 6.) readArray() Populates the elements of the array with input from the user (or via file redirection). 7.) printArray() Prints the elements of the array. *You may use any sorting algorithm that you want. Here are a few easy suggestions: Bubble sort pseudocode: do swapped = false for each i in 1 to length(A) inclusive do: if A[i-1] > A[i] then swap A[i-1] and A[i] swapped = true end if end for while swapped Insertion sort pseudocode: i ← 1 while i < length(A) j ← i while j > 0 and A[j-1] > A[j] swap A[j] and A[j-1] j ← j - 1 end while i ← i + 1 end while Additional Specifications: Your program should not use any pre-existing classes such as string or vector classes! Make sure your program compiles and runs on one of the Linux machines in the Linux lab before you submit. Your program should consist of a single source code. EXAMPLE OUTPUT: casey@vanderwaal:-/Dropbox/Teaching/CSCE24oFalt2617/Projects/Assignment2$ g++ Assignment2.cpp casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ ./a.out Please enter the size of your array: 6 Please enter 6 elements to populate the array. 212.3-6799 θ The elements of the array are: 212.3-6 7 99 θ The elements of the array sorted in ascending order: 6 0 27 12.3 99 The min of the array is-6 The max of the array is 99 The mean of the array is 19.05 The median of the array is 4.5 casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ Examples using file redirection:
    casey@vanderwaal:-/Dropbox/Teaching/CSCE24oFalt2617/Projects/Assignment2$ g++ Assignment2.cpp casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ ./a.out Please enter the size of your array: 6 Please enter 6 elements to populate the array. 212.3-6799 θ The elements of the array are: 212.3-6 7 99 θ The elements of the array sorted in ascending order: 6 0 27 12.3 99 The min of the array is-6 The max of the array is 99 The mean of the array is 19.05 The median of the array is 4.5 casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$

    Expert Answer

     
    Here is your c++ program: C++ Program:

    C++ Assignment

    Description:

    Develop a program that calculates basic statistics on a unique-dimensional adorn of doubles. Your program should primitive active the explanationr coercion the extent of the adorn followed by activeing coercion specific elements of the adorn. Your program should comprise the aftercited functions:

    1.) min()

    Finds and profits the narrowness prize among the adorn.

    2.) max()

    Finds and profits the zenith prize among the adorn.

    3.) average()

    Finds and profits the average prize of the elements in the adorn.

    4.) median()

    Finds and profits the median prize of the elements in the adorn.

    5.) description()*

    Sorts the elements of the adorn in ascending ordain.

    6.) readArray()

    Populates the elements of the adorn with input from the explanationr (or via perfect redirection).

    7.) printArray()

    Prints the elements of the adorn.

    *You may explanation any descriptioning algorithm that you deficiency. Here are a lacking manageable suggestions:

    Bubble description pseudocode:

    do
    swapped = false
    coercion each i in 1 to elongation(A) additive do:
    if A[i-1] > A[i] then
    swap A[i-1] and A[i]
    swapped = true
    end if
    end coercion
    while swapped

    Insertion description pseudocode:

    i ← 1
    while i < elongation(A)
    j ← i
    while j > 0 and A[j-1] > A[j]
    swap A[j] and A[j-1]
    j ← j – 1
    end while
    i ← i + 1
    end while

    Additional Specifications:

    Your program should not attributable attributable attributable explanation any pre-existing classes such as string or vector classes!

    Make positive your program compiles and runs on unique of the Linux machines in the Linux lab precedently you yield.

    Your program should halt of a unique fountain method.

    EXAMPLE OUTPUT:

    casey@vanderwaal:-/Dropbox/Teaching/CSCE24oFalt2617/Projects/Assignment2$ g++ Assignment2.cpp casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ ./a.quenched Please penetrate the extent of your adorn: 6 Please penetrate 6 elements to populate the adorn. 212.3-6799 θ The elements of the adorn are: 212.3-6 7 99 θ The elements of the adorn descriptioned in ascending ordain: 6 0 27 12.3 99 The min of the adorn is-6 The max of the adorn is 99 The average of the adorn is 19.05 The median of the adorn is 4.5 casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$

    Examples using perfect redirection:

    casey@vanderwaal:-/Dropbox/Teaching/CSCE24oFalt2617/Projects/Assignment2$ g++ Assignment2.cpp casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ ./a.quenched Please penetrate the extent of your adorn: 6 Please penetrate 6 elements to populate the adorn. 212.3-6799 θ The elements of the adorn are: 212.3-6 7 99 θ The elements of the adorn descriptioned in ascending ordain: 6 0 27 12.3 99 The min of the adorn is-6 The max of the adorn is 99 The average of the adorn is 19.05 The median of the adorn is 4.5 casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$

    Expert Reply

     

    Here is your c++ program:

    C++ Program:

    #include<iostream>

    #include<conio.h>

    using namespace std;

    double arra[100];

    static int n;

    void average()//to perceive average

    {

    double sum=0;

    for(int i=0;i<n;i++)

    sum+=arra[i];

    cout<<“nThe average of the adorn is “<<sum/n;

    }

    void median()//to perceive median

    {

    int mid=n/2;

    if(n%2!=0)

    {

    int temp=((n+1)/2)-1;

    cout<<“nThe median of the adorn is “<<arra[temp];

    }else

    {

    cout<<“nThe median of the adorn is “<<arra[(n/2)-1];

    }

    }

    void min()//to perceive min

    {

    double low;

    low=arra[0];

    for(int i=1;i<n;i++)

    {

    if(low>arra[i])

    low=arra[i];

    }

    cout<<“nThe min of the adorn is “<<low;

    }

    void max()//to perceive max

    {

    double high=arra[0];

    for(int i=1;i<n;i++)

    {

    if(high<arra[i])

    high=arra[i];

    }

    cout<<“nThe max of the adorn is “<<high;

    }

    void description()//to description adorn

    {

    double temp;

    for(int i=0;i<n;i++)

    {

    for(int j=0;j<n;j++)

    {

    if(i==j)

    continue;

    else

    if(arra[i]<arra[j])

    {

    temp=arra[j];

    arra[j]=arra[i];

    arra[i]=temp;

    }

    }

    }

    cout<<“n The elements of the adorn descriptioned in ascending ordain:n”;

    for(int i=0;i<n;i++)

    cout<<arra[i]<<” “;

    }

    void deep()

    {

    double input;

    cout<<“Penetrate the extent of adornn”;

    cin>>n;

    cout<<“penetrate Adorn Elementn”;

    for(int i=0;i<n;i++)

    {

    cin>>input;

    arra[i]=input;

    }

    sort();

    min();

    max();

    mean();

    median();

    getch();

    }

    I prospect this solves your problem