now all of the errors are gone but the only thing printing is the headings.
could someone look at this and see what is wrong. here are the instructions word for word.
write a program that reads the students name together with his or her test scores. the program should compute the average test score for each student and assign the appropriet grade.
a.) a void function, calculateaverage, to determin the average of the five testscores for each student. use a loop to read and sum the test scores. this function does not output the average test score. that is done in main.
b.) a value returning function,calculategrade, to determin and return each students grade. this function does not output the grade that is done in main.
do not use global variables
the infile is in the previous note.
Thank you very much.
Code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
void calculatescore();
int calculategrade();
int main ()
{
string studentname;
int total;
int totalscore;
int test1;
int test2;
int test3;
int test4;
int test5;
int grade;
int average;
ifstream infile;
ofstream outfile;
infile.open("g:\\student.txt");
outfile.open("g:\\grades.txt");
outfile << fixed << showpoint << setprecision(2);
outfile << left << setw(20) << "Student Name"
<< setw(10) << "Test 1"
<< setw(10) << "Test 2"
<< setw(10) << "Test 3"
<< setw(10) << "Test 4"
<< setw(10) << "Test 5"
<< setw(10) << "Average"
<< setw(10) << "Grade" << endl;
while (infile >> studentname);
{
{
grade = calculategrade();
calculatescore();
average = total / 5;
}
outfile << left << setw(20) << studentname
<< setw(25) << test1
<< setw(15) << test2
<< setw(15) << test3
<< setw(15) << test4
<< setw(10) << test5
<< setw(20) << average
<< setw(15) << grade << endl;
}// end while
infile >> studentname;
}
void calculatescore()
{
int total;
int test1;
int num = test1, test2, test3, test4, test5;
string studentname;
int counter;
ifstream infile;
infile >> studentname >> test1 >> test2 >> test3 >> test4 >> test5;
counter = 0;
while (counter < 4)
{
total = 0;
infile >> num;
while (num != -999);
{
total = total + num;
counter++;
infile >> num;
}
}
}
int calculategrade()
{
int total;
int grade;
int A;
int B;
int C;
int D;
int F;
int average;
calculatescore();
average = total / 5;
{
if (average >= 90)
return A;
if (average >= 80)
return B;
if (average >= 70)
return C;
if (average >= 60)
return D;
if (average < 60)
return F;
}
}