#include "STDAFX.H"
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cstdlib>
using namespace std;
class Subject
{
private:
string code;
int cu;
char pf;
public:
Subject(void);
void setCode(string);
void setCU(int);
void setPF(char);
};
class Student
{
private:
string name;
int count;
int totalCU;
Subject subjects[4];
public:
Student(void);
void setName(string);
void setCount(int);
void setTotalCU(int);
void setSCode(string,int);
void setSCU(int,int);
void setSpf(char,int);
string getName(void);
int getSCount(void);
int getTCU(void);
};
// implementation section
// set the total count for passed subjects
void Student::setCount(int cPass)
{
count = cPass;
}
// set the total credit units of passed subjects
void Student::setTotalCU(int PassTotalCU)
{
totalCU = PassTotalCU;
}
// set the subject code for the ith subject
void Student::setSCode(string subject,int i)
{
}
// set the subject CU for the ith subject
void Student::setSCU(int,int)
{
}
// set the subject grade (pass or fail)
void Student::setSpf(char,int)
{
}
string Student::getName(void)
{
}
int Student::getSCount(void)
{
}
int Student::getTCU(void)
{
}
Subject::Subject(void)
{
}
void Subject::setCode(string c)
{
code = c;
}
void Subject::setCU(int u)
{
cu = u;
}
void Subject::setPF(char p)
{
pf = p;
}
// end implementation section
int main()
{
Student students[4];
int count, cu, totalCU;
string name, code;
char pf;
ifstream inFile;
// declare other relevant variables here
inFile.open("C:\\student.dat");
if (!inFile.good())
{
cout << "File not found" << endl;
return 1;
}
while(!inFile.eof())
{
// use getline to read entire line
getline(inFile, s);
cout << s << endl;
}
// Part (ii): code goes here
}
The question:
Each student takes up to 4 subjects. The first field in each record is a
name, followed by each subject’s code, number of credit units and
grade of the subject. The grade for each subject is either a P or F; P
means pass while F means fail.
Student.dat
Peter Subject1 4 F Subject2 3 P Subject3 5 P Subject4 5 P
Ali Subject1 4 P Subject2 3 P Subject3 5 P Subject4 5 P
Janet Subject1 4 F Subject2 3 F Subject3 5 P Subject4 5 P
Koh Subject1 4 P Subject2 3 P Subject3 5 P Subject4 5 P
I'm suppose to get the values from student.dat and pass them in to an array, but i cant seem to think of a way to implement the student class. can someone help me out?