Given the following, how do I get the program to print-off cut-off values?. For each exam, the A cut-off is 0.9* the highest score. B cut-off is 0.8 * the highest , C cut-off is 0.7* the highest value and D cut-off is 0.6 * the highest value. I want it to print-out a table with A to D cut-offs as well as cut-off totals. This makes 4 columns(1 for each exam and 1 for totals) as well as 4 rows(A to D cut-offs). I got the result, but my method involves calling the GetHighestValue(exam1Array) function 3 times, for the three dirfferent arrays and manually multipling them out. It works but it's crude. i would prefer using a function. I am just a little lost as to how to design that function. Thanks!!
Code://Sample Program 12- A non-interactive program to calculate student grades. //************************************************************************************** #include<iostream> #include<iomanip> #include<fstream> #include<string> using namespace std; const int SIZE=6; int GetHighValue(int array[]); int main() { int exam1Array[SIZE]; int exam2Array[SIZE]; int exam3Array[SIZE]; int i=0; string name; ifstream inFile; inFile.open("grades.dat"); if(!inFile) { cout<<"Unable to open input file, program abnormally ended"; return 1; } for(i=0; i<SIZE; i++) { inFile>>name>>exam1Array[i]>>exam2Array[i]>>exam3Array[i]; } GetHighValue(exam1Array); cout<<"The highest for exam 1 is"<<GetHighValue(exam1Array)<<endl; GetHighValue(exam2Array); cout<<"The highest for exam 2 is"<<GetHighValue(exam2Array)<<endl; GetHighValue(exam3Array); cout<<"The highest for exam 3 is"<<GetHighValue(exam3Array)<<endl; return 0; } int GetHighValue(/*in*/ int array[]) { int highScore=0; int i=0; for(i=0; i<SIZE; i++) { if(array[i]>highScore) highScore=array[i]; } return highScore; }



LinkBack URL
About LinkBacks


