The file is a .dat file and I was able to read into the file but I can't find a way to access the data separated by the space so that I can calculate the year mark for the subject as a percentage.
The first field in each line represents the subject code.
followed by the percentage assignment 1 contributes towards the year mark,
followed by the students mark they got on assignment 1,
followed the percentage assignment 2 contributes towards the year mark,
followed the students' mark they got on assignment 2.
To view, the file data, Open the image link at the end of the code.
My code so far:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
string line_;
ifstream yearmark;
yearmark.open ("assignments.dat");
if (yearmark.is_open())
{
while (getline (yearmark,line_))
{
cout<< line_<<'\n';
}
yearmark.close();
}
else
{
cout<< "file not open"<< endl;
}
cout<< endl;
ofstream file ("yearmarks.dat");
file.close();
return 0;
}