#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string subject;
char grade;
double gradePoint;
ofstream fout;
while(true)
{
cout << "What is the subject? ";
getline(cin,subject);
cout << "What is your grade [A-F]? ";
cin >> grade;
cin.ignore(1000,10);
if (toupper(grade) == 'A')
{
gradePoint = 4.0;
}
else
{
if (toupper(grade) == 'B')
{
gradePoint = 3.0;
}
else
{
if (toupper(grade) == 'C')
{
gradePoint = 2.0;
}
else
{
if (grade == 'D' || grade == 'd')
{
gradePoint = 1.0;
}
else
{
gradePoint = 0;
break;
}
}
}
} // A !A
cout << "your grade point is " << gradePoint << endl;
fout.open("gradePointList.txt", ios::app);
// if(!fout.good()){ throw "I/O Error";}
if(!fout.good()) throw "I/O Error";
fout << gradePoint << endl;
fout.close();
} // while
return 0;
}
No comments:
Post a Comment