Would you please help me with this assignment.
I am supposed to create a txt file that contains ID and mark for three students and the output should be the ID and a message in a different txt file.
When I try running the code, the output txt file is blank. I tried changing the code so the program outputs results on screen, but for some reason it doesn't read the first line and it repeats the third!
I'm using Visual studio 2012.
input data:
20112233 90
20115566 80
20113756 70
Here is my code:
#include <iostream>
#include <fstream>
using namespace std;
void main ()
{
int ID, mark, c=1;
ifstream fin;
fin.open ("marks.txt");
fin >> ID >> mark;
ofstream fout;
fout.open ("grades");
while (c<=3)
{
fin >> ID >> mark;
if (mark >= 90 && mark <= 100) {
fout << ID << "\t" << "Excellent" << endl;
c++;
}
else if (mark >= 80 && mark <= 89) {
fout << ID << "\t" << "Very Good" << endl;
c++;
}
else if (mark >= 70 && mark <= 79) {
fout << ID << "\t" << "Good" << endl;
c++;
}
else if (mark >= 60 && mark <= 69) {
fout << ID << "\t" << "Accepted" << endl;
c++;
}
else if (mark >= 0 && mark <= 59) {
fout << ID << "\t" << "Fail" << endl;
c++;
}
else fout << "Wrong data";
}
fin.close ();
fout.close ();
system ("PAUSE");
}