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

Modify the Test Scores program from the above Debug Section into a class grade b

ID: 3539850 • Letter: M

Question

Modify the Test Scores program from the above Debug Section into a class grade book that

includes a class of up to 20 students and 3 test grades. Each test is read in as a separate

file, so 3 Test files are required. The students grades should be kept in an array. Once

all three test scores are read in, calculate each students average and grade for the class.

Also print a report of the each students test grades, average and final grade as a

table, and then print the averages of each Test and overall Test Average, as well as

highest Test Grade of all Tests and the student with the highest class grade.




#include <iostream>

#include <iomanip>

#include<fstream>

using namespace std;

void readData(ifstream& inputFile, int list[], int size);

void holdscrn( );    // void function to hold screen open before exit

void print(int list[], int size);//.....error2

int main()

{

    int scores[8] = {0};

    ifstream infile;

    infile.open("TestScoresData.txt");

          if (!infile)

          {

                   cout << "Cannot open the input file. Program terminates!"

                             << endl;

                   holdscrn( );   // Hold screen before exit      

                   return 1;

          }

          readData(infile, scores, 8);

          print(scores, 8);

          cout << endl;

          infile.close();

          holdscrn( );   // Hold screen before exit

          return 0;

}

void readData(ifstream& inputFile, int list[], int size)

{

          int score;

          int index;

          inputFile>> score;

          while (inputFile)

          {

                   index = score / 25;

                   if (index == size)

                             index--;

                   if (index >=0 && index

                             list[index]++;

                   inputFile >> score;

          }

    //return 0;

}

void print(int list[], int size)

{

    int range;

    int lowRange = 0;

    int upperRange = 24;

    cout << "   Range       # of Students" << endl;

    for (range = 0; range < size; range++)

    {

        cout << setw(3) << lowRange << " - "

             << upperRange << setw(15)

             << list[range] << endl;

        lowRange = upperRange + 1;

        upperRange = upperRange + 25;

        if (range == size - 2)

            upperRange++;

    }

    cout << endl;

    return;

}

void holdscrn( )   // void function to hold screen open before exit

{

    char holdscreen;

    cout << " Enter one character and press return to exit program: ";

    cin >> holdscreen;

    return;

}

Explanation / Answer

check it .....

u just missed one brace.....

#include <iostream>


#include <iomanip>


#include<fstream>



using namespace std;



void readData(ifstream& inputFile, int list[], int size);


void holdscrn( ); // void function to hold screen open before exit


void print(int list[], int size);//.....error2



int main()


{


int scores[8] = {0};



ifstream infile;



infile.open("TestScoresData.txt");



if (!infile)


{


cout << "Cannot open the input file. Program terminates!"


<< endl;


holdscrn( ); // Hold screen before exit


return 1;


}



readData(infile, scores, 8);


print(scores, 8);


cout << endl;



infile.close();


holdscrn( ); // Hold screen before exit


return 0;


}



void readData(ifstream& inputFile, int list[], int size)


{


int score;


int index;



inputFile>> score;



while (inputFile)


{


index = score / 25;



if (index == size)


index--;


if (index >=0 && index)


list[index]++;



inputFile >> score;


}


//return 0;


}



void print(int list[], int size)


{


int range;


int lowRange = 0;


int upperRange = 24;



cout << " Range # of Students" << endl;



for (range = 0; range < size; range++)


{


cout << setw(3) << lowRange << " - "


<< upperRange << setw(15)


<< list[range] << endl;


lowRange = upperRange + 1;


upperRange = upperRange + 25;


if (range == size - 2)


upperRange++;


}


cout << endl;


return;


}



void holdscrn( ) // void function to hold screen open before exit


{


char holdscreen;


cout << " Enter one character and press return to exit program: ";


cin >> holdscreen;



return;


}

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