Write a program that reads input file ¡§grades.txt¡¨ to EOF and inputs a 5 digit student ID number followed by 6 test
grades then another 5 digit student ID number followed by another 6 test grades for up to 15 students. The grade data
is to be loaded into a two-dimensional array with 15 rows and 6 columns that would parallel an integer array storing the
student ID numbers. The program then needs to produce the following output to a named ¡§prog8_out_<Your
NetID>.txt¡¨.
For each student:
„h Student IDNo followed by the 6 test grades for each student.
„h The test average for each student to the nearest whole number. (Use a function that has the grade array and
row number as arguments and returns the test average for that student. This function should only perform this
one task.)
For each test:
„h The class average for each test to the nearest whole number. (Use a function that has the grade array, number
of actual students and test number as arguments and returns the class average for that test. This function
should only perform this one task.)
One additional required function: Use a function that has the grade array, ID number array and an integer passed by
reference as its arguments. It should perform the task of reading the data from the input file into the arrays. The
function should return the number of student records read from the file via the integer argument passed by reference.
The return value of the function should be bool. It will return true if the input file is successfully opened and read;
otherwise, it returns false. Example Prototype: bool GetData(float [ ][NO_GRADES], int [], int&)
Array sizes should be implemented with global named constants.
This program is due by noon on Tuesday, December 4.
You may create other unspecified functions if you so wish as long as the four functions described are implemented and
used.
(Sample input file contents and output file contents on next page.)
Sample Input
12345 68 79 78 83 94 67
34213 98 87 92 90 88 91
65476 75 81 80 74 90 79
43432 64 54 71 69 51 78
76565 85 82 91 87 90 83
12654 35 78 56 24 75 62
43444 67 78 75 80 85 71
Sample Output:
Student ID: 12345
68 79 78 83 94 67
Test Avg = 78
Student ID: 34213
98 87 92 90 88 91
Test Avg = 91
Student ID: 65476
75 81 80 74 90 79
Test Avg = 80
Student ID: 43432
64 54 71 69 51 78
Test Avg = 64
Student ID: 76565
85 82 91 87 90 83
Test Avg = 86
Student ID: 12654
35 78 56 24 75 62
Test Avg = 55
Student ID: 43444
67 78 75 80 85 71
Test Avg = 76
Class Avg for Test # 1 is 70
Class Avg for Test # 2 is 77
Class Avg for Test # 3 is 78
Class Avg for Test # 4 is 72
Class Avg for Test # 5 is 82
Class Avg for Test # 6 is 76
I need help on figuring out how to get the test average.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include <fstream>
using namespace std;
int QuizGrades[15][6];
int ID[15];
int row = 0;
bool GetData(QuizGrades,ID[row],row&)
{
int row = 0;
int column =0;
ifstream input;
input.open("input.txt");
while(row < 15 && input >> ID[15])
{
for(column =0; column < 6; column ++)
{
input >> QuizGrades[row][column];
row ++;
}
}
if (input)
{
return true;
}
else
return false;
}
int StudentAvg(QuizGrades,row)
{
int Average = 0;
Average = QuizGrades / 7;
return Average;
}
int TestAvg(QuizGrades,row,)
{
int Test1,Test2,Test3,Test4,Test5,Test6 =0;
return TestAvg;
}
int main()
{
ofstream fout;
fout.open("prog9_out_jrh195.txt");
fout.close();
return 0;
}
|