hey i got this program to calculate grades by reading from a file but im getting some error. can anybody help.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int highestGrade (int score1, int score2, int score3);// prototype for first function
char letterGrade (int highscore);// prototype second function
int main(){
string name;
int grade1, grade2 , grade3;
ifstream inputFile;
inputFile.open("Text.txt");
if (inputFile.fail())
{
cout << "Opening error";
}
ofstream outputfile;
outputfile.open("MyResult.txt");
char letter;
while (!inputFile.eof()){
inputFile >> name;
inputFile >> grade1;
inputFile >> grade2;
inputFile >> grade3;
//highestGrade (12,14,15);
int maxgrade = highestGrade(grade1, grade2, grade3);
letter = letterGrade(maxgrade);
// or can use
//letter = letterGrade(higestGrade(maxgrade));
//write your result.
}
int highestGrade (int score1, int score2, int score3)
{
if (score1 >=score2 && score1 >= score3) return score1;
if (score2 >=score1 && score2 >= score3) return score2;
if (score3 >=score2 && score3 >= score2) return score3;
}
char letterGrade (int highscore) {
if (highscore >= 90 && highscore <=100) return 'A';
if (highscore >= 80 && highscore <= 89) return 'B';
if (highscore >= 70 && highscore <= 79) return 'C';
if (highscore >= 70 && highscore <= 79) return 'D';
if (highscore < 69) return 'F';
}
inputFile.close();
outputfile.close();
cout<< highestGrade<<letterGrade;
system("pause");
return 0;
}