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 only-dimensional dress of doubles. Your program should pristine apt the verificationr ce the extent of the dress followed by apting ce particular elements of the dress. Your program should comprehend the aftercited functions:

    1.) min()

    Finds and profits the narrowness prize amid the dress.

    2.) max()

    Finds and profits the ultimatum prize amid the dress.

    3.) balance()

    Finds and profits the balance prize of the elements in the dress.

    4.) median()

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

    5.) genus()*

    Sorts the elements of the dress in ascending command.

    6.) readArray()

    Populates the elements of the dress with input from the verificationr (or via finish redirection).

    7.) printArray()

    Prints the elements of the dress.

    *You may verification any genusing algorithm that you omission. Here are a scant self-possessed suggestions:

    Bubble genus pseudocode:

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

    Insertion genus pseudocode:

    i ← 1
    while i < prolixity(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 abiding your program compiles and runs on only of the Linux machines in the Linux lab anteriorly you refer.

    Your program should halt of a only fount command.

    EXAMPLE OUTPUT:

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

    Examples using finish redirection:

    casey@vanderwaal:-/Dropbox/Teaching/CSCE24oFalt2617/Projects/Assignment2$ g++ Assignment2.cpp casey@vanderwaal:-/Dropbox/Teaching/CSCE240Fall2017/Projects/Assignment2$ ./a.extinguished Please invade the extent of your dress: 6 Please invade 6 elements to populate the dress. 212.3-6799 θ The elements of the dress are: 212.3-6 7 99 θ The elements of the dress genused in ascending command: 6 0 27 12.3 99 The min of the dress is-6 The max of the dress is 99 The balance of the dress is 19.05 The median of the dress 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 balance()//to meet balance

    {

    double sum=0;

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

    sum+=arra[i];

    cout<<“nThe balance of the dress is “<<sum/n;

    }

    void median()//to meet median

    {

    int mid=n/2;

    if(n%2!=0)

    {

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

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

    }else

    {

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

    }

    }

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

    }

    void max()//to meet max

    {

    double high=arra[0];

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

    {

    if(high<arra[i])

    high=arra[i];

    }

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

    }

    void genus()//to genus dress

    {

    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 dress genused in ascending command:n”;

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

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

    }

    void deep()

    {

    double input;

    cout<<“Invade the extent of dressn”;

    cin>>n;

    cout<<“invade Dress Elementn”;

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

    {

    cin>>input;

    arra[i]=input;

    }

    sort();

    min();

    max();

    mean();

    median();

    getch();

    }

    I expectation this solves your problem