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 invest of doubles. Your program should chief responsive the correctionr for the dimension of the invest followed by responsiveing for solitary elements of the invest. Your program should inclose the aftercited functions:

    1.) min()

    Finds and profits the poverty compute amid the invest.

    2.) max()

    Finds and profits the apex compute amid the invest.

    3.) medium()

    Finds and profits the medium compute of the elements in the invest.

    4.) median()

    Finds and profits the median compute of the elements in the invest.

    5.) designation()*

    Sorts the elements of the invest in ascending ordain.

    6.) readArray()

    Populates the elements of the invest with input from the correctionr (or via improve redirection).

    7.) printArray()

    Prints the elements of the invest.

    *You may correction any designationing algorithm that you scantiness. Here are a lacking comfortable suggestions:

    Bubble designation pseudocode:

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

    Insertion designation pseudocode:

    i ← 1
    while i < diffusiveness(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 correction 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 precedently you succumb.

    Your program should rest of a solitary spring adjudication.

    EXAMPLE OUTPUT:

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

    Examples using improve redirection:

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

    Expert Apology

     

    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 invest 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 invest is “<<arra[temp];

    }else

    {

    cout<<“nThe median of the invest 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 invest 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 invest is “<<high;

    }

    void designation()//to designation invest

    {

    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 invest designationed in ascending ordain:n”;

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

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

    }

    void deep()

    {

    double input;

    cout<<“Invade the dimension of investn”;

    cin>>n;

    cout<<“invade Invest 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