grades.cxx
Transcript of grades.cxx
-
7/31/2019 grades.cxx
1/4
//grades.cxx1/31/2012//[email protected]//Agradesprogramdesignedtotakeina//studentidand5quizscoresthensort//theminthedesiredorderanddisplay//withaveragesincluded.
#include#includeusingnamespacestd;
//Prototypes//Takesina2demensionaldoublearraywithaizeandacolumntofocuson.//Thensortsthemfromsmallesttolargest.voidbubbleSort(doublestudents[50][7],intsize,intcol);//Computestheavarageforallquizesinthe7thcolumnforeachstudentvoidcomputeAvg(doublestudents[50][7],intsize);//Ahelpermeathodthatreturnstheaverageofaarrayofdoubles//UsedtocomputetheclassaveragedoublecomputeAvgG(doublenums[50],intsize);//Takesinallnumberdataandstoresitinadoublearrayassertingthefirst//numberisarealnum>0.Thentakesincharsandstorestheminaarray
//untilTisentered.voidinputData(doublestudents[50][7],int&size,charcmnds[100],int&sizeC);//PrintsintheproperformattheexpectedoutputvoidprintList(doublestudents[50][7],intsize);//Exacutesthecommandsinthecmndsarrayanddecideshowtosortusing//aswitchstatement.voidrunCmnds(doublestudents[50][7],intsize,charcmnds[100],intsizeC);//Swapstwostudentsatpositionsaandbbyswitchingallvalues.voidswap(doublestudents[50][7],inta,intb);
//------------------------------------------------------------------------------intmain(){doublestudents[50][7];intsize;charcmnds[100];intsizeC;
inputData(students,size,cmnds,sizeC);computeAvg(students,size);runCmnds(students,size,cmnds,sizeC);
return0;}//------------------------------------------------------------------------------
//------------------------------------------------------------------------------voidbubbleSort(doublestudents[50][7],intsize,intcol){for(inti=0;i
-
7/31/2019 grades.cxx
2/4
}}//------------------------------------------------------------------------------
//------------------------------------------------------------------------------voidcomputeAvg(doublestudents[50][7],intsize){doubletemp=0;
for(inti=0;i0);
for(inti=0;istudents[i][j];}}
inti=0;while(temp!='T'){cin>>temp;cmnds[i]=temp;i++;
}sizeC=(i-1);}//------------------------------------------------------------------------------
//------------------------------------------------------------------------------voidprintList(doublestudents[50][7],intsize){doubleq1[50];doubleq2[50];doubleq3[50];
-
7/31/2019 grades.cxx
3/4
doubleq4[50];doubleq5[50];
for(inti=0;i
-
7/31/2019 grades.cxx
4/4
for(inti=0;i