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

On a given exam, the points awarded for each problem are recorded in a text file

ID: 3641864 • Letter: O

Question


On a given exam, the points awarded for each problem are recorded in a text file, with one line of the file for each student that took the exam. Create a program that reads this text file and determines
· each student’s total grade for the exam
· the class average for the exam
· the average number of points given for each problem
Program Requirements
· The input data file will be a plain text file with each number separated by a single space.· All numerical data (student ID, scores) must be stored in a 2-dimensional array.
o The final column of the array should hold the total score for each student. Caution: do not include the student ID in the average!
o The final should hold the averages for each column.
o There will be 4 problems and 5 students, so the array should hold 6 rows (5 students + average) and 6 columns (ID, 4 grades, and exam total).
· All calculations and array access must be performed using pointers and dereferencing. You may use [ ] only when reading and writing the data files.
· The results must be printed to the screen as well as written to a file in table format.
Program Organization
Your program should contain the following functions: main, loadDataFile, calculateResults, writeResultsFile, and printResults.
· main – create empty 6x6 2-D array to hold data and then call other functions as needed, passing them the array
· loadDataFile – read the input file, storing the data in the 2-D array
· calculateResults – performs all calculations
· writeResultsFile – creates and writes the resulting array to the output data file
· printResults – prints the results to the screen

Example Input:
1 20 22 12 10
2 20 10 19 25
3 10 0 20 21
4 25 25 25 25
5 15 20 19 17


Example Output File
1 20 22 12 10 64
2 20 10 19 25 74
3 10 0 20 21 51
4 25 25 25 25 100
5 15 20 19 17 71
0 18 15.4 19 19.6 72

Explanation / Answer

#include #include #include #include using namespace std; //Make the student and grade array double studentScores[6][6]; void loadDataFile() { //Variables for counting purposes int i = 0, j = 0; //Make the ifstream object and open the file to be read ifstream inFile("input.txt"); //Read the data from the file while(!inFile.eof()) { for(j = 0; j < 5; ++j) inFile >> studentScores[i][j]; ++i; } } void calculateResults() { double total; //Fill the totals column for(int i = 0; i < 5; ++i) { total = 0; for(int j = 1; j < 5; ++j) { total += *( *(studentScores+i) + j); } *( *(studentScores+i) + 5) = total; } //Then fill the averages column for(int i = 1; i < 6; ++i) { total = 0; for(int j = 0; j < 5; ++j) { total += *( *(studentScores+j) + i); } *( *(studentScores+5) + i) = total/5; } } void writeResultsFile() { ofstream outFile("output.txt"); for(int i = 0; i < 6; ++i) { for(int j = 0; j < 6; ++j) { outFile
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