Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5210.0 sMitH,BoB 12000.0 joNes,ANAbel 800.0 thoMas,miCHaEl 25000.0 mILToN,mARTy

ID: 3610941 • Letter: 5

Question

5210.0 sMitH,BoB
12000.0 joNes,ANAbel
800.0 thoMas,miCHaEl
25000.0 mILToN,mARTy

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;

const int SIZE = 25; //Size ofarrays

int main()
{
double SalesAmounts [SIZE]={0.0}; //Sales amounts array
string SalesReps [SIZE]; //Names of sales representativesarray
ifstream infile; //Input filestream variable
string fnameopen, fnameclose; //Variables to hold actualname of file
double sum;
int counter=0; //used in for loops
double average; //average of sales amount
int MaxIndex; //used to find the array with the largestvalue
double LargestSale; //variable to hold the largest value
int numElements=counter-1;

cout<<"Please enter name ofinput file"<<endl;
cin>>fnameopen;
infile.open(fnameopen.c_str());
cout<<"Please enter name of outputfile"<<endl;
cin>>fnameclose;
cout<<"Hubbard Payroll Summary forNewTech"<<endl;

sum = 0;
for (counter=0; counter<SIZE&&infile;counter++)
    {
     infile>>SalesAmounts[counter];
     infile>>SalesReps[counter];
      sum = sum +SalesAmounts[counter];
    }
counter--;

//median sales amount
//cout<<"NUMELEMENTS:"<<numElements;

for(int p =1; p<numElements; p++)
    {
      for(int q=0; q<p; q++)
        {
         if(SalesAmounts[q] > SalesAmounts[p])
           {
             double temp=SalesAmounts[q];
             SalesAmounts[q]= SalesAmounts[p];
             SalesAmounts[p]= temp;
           }
        }
    }


      cout<<"Median sales:"<<setw(9)<<"$"<<setw(10)
          <<(SalesAmounts[(numElements/2)-1] + SalesAmounts[(numElements/2)])/2<<endl;
    }
else
    {
      int median =(numElements/2);
      cout<<"Median sales:"<<setw(9)<<"$"<<setw(10)<<SalesAmounts[median]<<endl;
    }

MaxIndex = 0;
for(counter=1; counter<SIZE; counter++)
    if(SalesAmounts[MaxIndex] <SalesAmounts[counter])
      MaxIndex = counter;
LargestSale =SalesAmounts[MaxIndex];

return 0;
}


Explanation / Answer

#include #include #include #include using namespace std; const int SIZE = 25; //Size of arrays int main() { double SalesAmounts [SIZE]={0.0}; //Sales amounts array string SalesReps [SIZE]; //Names of sales representativesarray ifstream infile; //Input filestream variable string fnameopen, fnameclose; //Variables to hold actualname of file double sum; int counter=0; //used in for loops double average; //average of sales amount int MaxIndex; //used to find the array with the largestvalue double LargestSale; //variable to hold the largest value cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote