Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ Some issues with functions for a program
    primarykey
    data
    text
    <p>So i am having issues with the Void printresult function.<br> I can't get it to work the compiler error i get is outFile is not declared and highest score "Expression preceding parentheses of apparent call must have (pointer-to-) function type. Some direction would be appreciated.</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;fstream&gt; #include &lt;iomanip&gt; using namespace std; const int NO_OR_STUDENTS = 20; struct studentType { string studentFName; string studentLName; int testScore; char grade; }; void getData(ifstream&amp; inFile, studentType sList[], int listSize); void calculateGrade(studentType sList[], int listSize); int highestScore(const studentType sList[], int listSize); void printResult(ofstream&amp; outFile, const studentType sList[], int listSize); int main() { ifstream inData; ofstream outData; studentType studentList[NO_OR_STUDENTS]; inData.open("Ch9_Ex2Data.txt"); if(!inData) { cout &lt;&lt; "The input file does not exist. Program terminates!" &lt;&lt; endl; system("PAUSE"); return 1; }//endif outData.open("Ch11_Ex1Out.txt"); if(!outData) { cout &lt;&lt; "Cannot open the output file. Program terminates!" &lt;&lt; endl; system("PAUSE"); return 1; }//endif getData(inData, studentList, NO_OR_STUDENTS); calculateGrade(studentList, NO_OR_STUDENTS); printResult(outData, studentList, NO_OR_STUDENTS); system("PAUSE"); return 0; }//endmain void getData(ifstream&amp; inFile, studentType sList[], int listSize) { for(int i = 0; i &lt; listSize; i++) inFile &gt;&gt; sList[i].studentFName &gt;&gt; sList[i].studentLName &gt;&gt; sList[i].testScore; }//endgetData void calculateGrade(studentType sList[], int listSize) { int score; for(int i = 0; i &lt; listSize; i++) if(score &gt;= 90) sList[i].testScore = 'A'; else if(score &gt;= 80) sList[i].testScore = 'B'; else if(score &gt;= 70) sList[i].testScore = 'C'; else if(score &gt;= 60) sList[i].testScore = 'D'; else sList[i].testScore = 'F'; //student writes code for this function }//endcalculateGrade int highestScore(const studentType sList[], int scores[], int listSize) //orignal parameters only had one array and an int //must pass in the scores array otherwise the program has no idea what it is inside the function { int highestScore = scores[0]; for(int i = 0; i &lt; listSize; i++) { if(scores[i] &gt; highestScore) { highestScore = scores[i]; } } } void printResult(ofstream&amp; outFile, const studentType sList[], int listSize) { int maxScore; int maxScore = highestScore(sList, listSize); int i; outFile &lt;&lt; setw(15) &lt;&lt; "Student Name " &lt;&lt; setw(10) &lt;&lt; "Test Score" &lt;&lt; setw(7) &lt;&lt; "Grade" &lt;&lt; endl; for(i = 1; i &lt; listSize; i++) outFile &lt;&lt; left &lt;&lt; setw(25) &lt;&lt; sList[i].studentLName + ", " + sList[i].studentFName &lt;&lt; right &lt;&lt; " " &lt;&lt; setw(5) &lt;&lt; sList[i].testScore &lt;&lt; setw(6) &lt;&lt; " " &lt;&lt; sList[i].grade &lt;&lt; endl; outFile &lt;&lt; endl &lt;&lt; "Highest Test Score: " &lt;&lt; maxScore &lt;&lt; endl; outFile &lt;&lt; "Students having the highest test score:" &lt;&lt; endl; for(i = 1; i &lt; listSize; i++) if(sList[i].testScore == maxScore) outFile &lt;&lt; sList[i].studentLName + ", " + sList[i].studentFName &lt;&lt; endl; }//endprintResult </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload