Can someone please write an application of fillioning questi

Can someone please write an application of fillioning question in C++ and please use comments to explain line of codes used so I can better understand.

Write a C++ application that asks the user to enter 10 numbers. The program then stores those numbers. The program should display the numbers sorted from low to high, from high to low, the Mean , Median, and Mode.

Do this using both #include \"until.h\"

Solution

// C++ application that asks the user to enter 10 numbers.
// The program then stores those numbers.
// The program should display the numbers sorted from low to high, from high to low, the Mean , Median, and Mode.

#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <fstream>
#include <iomanip>

using namespace std;

int main()
{
   // declare variables
   double median, mode;
   double array[10];
   int size = 10;
   double sum = 0;
   double mean = 0.0;
   double small,temp;
   int pos,k,c;

   // input 10 numbers from user
   for (int i = 0; i < size; ++i)
   {
       cout << \"Enter number \" << (i+1) << \": \";
       cin >> array[i];
       sum = sum + array[i];
   }
  
   // sort array low to high
   sort(array,array+size);
   cout << \"\ Low to high: \";
   for (int i = 0; i < size; ++i)
   {
       cout << array[i] << \" \";
   }

   cout << endl;

   // sort high to low
   for (int i = 0; i < size; ++i)
   {
       for (int j = 0; j < size; ++j)
       {
           if(array[j] < array[i])
               swap(array[i],array[j]);
       }
   }
   cout << \"\ high to low: \";
   for (int i = 0; i < size; ++i)
   {
       cout << array[i] << \" \";
   }
   cout << endl;

   for(int i=0;i<size-1;i++)
   {
       small=array[i];
       pos=i;

   for(int j=i+1;j<size;j++)
   {
       if(small>array[j])
       {
           small=array[j];
           pos=j;
       }
   }

       temp=array[pos];
       array[pos]=array[i];
       array[i]=temp;
   }

   mean = sum/size;
   cout<< \"\ Mean: \" << mean << endl;

   for(int i=0;i<size;i++)
   {
       for(int j=i+1;j<size;j++)
        {
            if(array[i]>array[j])
           {
               double t=array[i];
               array[i]=array[j];
               array[j]=t;
           }
        }
   }
   
    if(size%2==0)
        median=(float)(array[size/2]+array[(size-1)/2])/2;
    else
        median=array[(size-1)/2];
   
    cout << \"\ Median: \" << median << endl;

   
    int i, j,z, maxCount;
    double tmp, modeValue;
   int count[size] = {0};
  
     for(int i=0;i<size;i++)
         {
               for(int j=0;j<size-i;j++)
               {
                     if(array[j]>array[j+1])
                     {
                           tmp=array[j];
                           array[j]=array[j+1];
                           array[j+1]=tmp;
                     }
               }
         }
    for (int i = 0; i < size; i++)
    {
        for(z=i+1;z<size;z++)
        {
          
            if(array[i]==array[z])
            {
                count[i]++;
            }
        }
    }
  
  
    maxCount = 0;
    modeValue = 0;

    for (i = 1; i <= size; i++)
    {
        if (count[i] > maxCount)
        {
            maxCount = count[i];
            modeValue = array[i];
        }
    }
    cout << \"\ Mode: \" << modeValue << endl;


     cout << endl;


   return 0;
}

/*
output:

Enter number 1: 34
Enter number 2: 34
Enter number 3: 45
Enter number 4: 34
Enter number 5: 34
Enter number 6: 56
Enter number 7: 76
Enter number 8: 45
Enter number 9: 44
Enter number 10: 54

Low to high: 34 34 34 34 44 45 45 54 56 76

high to low: 76 56 54 45 45 44 34 34 34 34

Mean: 45.6

Median: 44.5

Mode: 76

*/

Can someone please write an application of fillioning question in C++ and please use comments to explain line of codes used so I can better understand. Write a
Can someone please write an application of fillioning question in C++ and please use comments to explain line of codes used so I can better understand. Write a
Can someone please write an application of fillioning question in C++ and please use comments to explain line of codes used so I can better understand. Write a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site