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 undivided-dimensional decorate of doubles. Your program should chief ready the verificationr coercion the largeness of the decorate followed by readying coercion indivisible elements of the decorate. Your program should embrace the subjoined functions:

    1.) min()

    Finds and income the minimum rate among the decorate.

    2.) max()

    Finds and income the utmost rate among the decorate.

    3.) medium()

    Finds and income the medium rate of the elements in the decorate.

    4.) median()

    Finds and income the median rate of the elements in the decorate.

    5.) designation()*

    Sorts the elements of the decorate in ascending appoint.

    6.) readArray()

    Populates the elements of the decorate with input from the verificationr (or via rasp redirection).

    7.) printArray()

    Prints the elements of the decorate.

    *You may verification any designationing algorithm that you insufficiency. Here are a scant quiet suggestions:

    Bubble designation 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 designation 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 referable verification any pre-existing classes such as string or vector classes!

    Make unquestioning your program compiles and runs on undivided of the Linux machines in the Linux lab antecedently you present.

    Your program should pause of a unmarried origin enactment.

    EXAMPLE OUTPUT:

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

    Examples using rasp redirection:

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

    Expert Rejoinder

     

    Here is your c++ program:

    C++ Program:

    #include<iostream>

    #include<conio.h>

    using namespace std;

    double arra[100];

    static int n;

    void medium()//to discover medium

    {

    double sum=0;

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

    sum+=arra[i];

    cout<<“nThe medium of the decorate is “<<sum/n;

    }

    void median()//to discover median

    {

    int mid=n/2;

    if(n%2!=0)

    {

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

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

    }else

    {

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

    }

    }

    void min()//to discover 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 decorate is “<<low;

    }

    void max()//to discover max

    {

    double high=arra[0];

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

    {

    if(high<arra[i])

    high=arra[i];

    }

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

    }

    void designation()//to designation decorate

    {

    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 decorate designationed in ascending appoint:n”;

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

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

    }

    void ocean()

    {

    double input;

    cout<<“Penetrate the largeness of decoraten”;

    cin>>n;

    cout<<“penetrate Decorate Elementn”;

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

    {

    cin>>input;

    arra[i]=input;

    }

    sort();

    min();

    max();

    mean();

    median();

    getch();

    }

    I confidence this solves your problem