End Google Ads 201810 - BS.net 01 --> Hi guys,

I have a following problem. I'm trying to read a range of data information from the following .dat file specified below.

I'm using the ifStream to read in the data from the Info.dat file. I have created the Student class object S[4], then using it to set the data that I've read in using variables. It is also a need for while loop to be used in the program. However, the problem is that it does not work out well.

My intended output is as such:

output:
------------
Alan
no of subjects taken: 4
no of passes :3
total credits : 17 and so on.

Really appreciate the help.


Info.dat
Alan English 4 F Maths 3 P Science 5 P Geo 5 P
Danny English 2 P Maths 3 P Science 4 P Geo 2 P
Jane English 1 F Maths 3 F Science 3 P Computing 8 P
Keith English 5 P Maths 3 P Science 5 P Literature 4 P



int main()
{
Student S[4]; //set the no. of students objects from Student Class here.
//Inside Student Class, there is another object called Modules[4], declared as private instance,
//which is used to initialise and called in the Student Class.


int count, credits, totalCred;
string stud, module;
char pass;

int Cols;
int Rows;

Cols = 0;
Rows = 0;


count = 0;
totalCU = 0;

ifstream inFile;

inFile.open("Info.dat");

if (inFile.fail()){
coutmodule>>credits>>pass;

//setting of each individual module variable data here.
S[Rows].setCode(module, Cols);
...

//Pass refers to the no. of passed subjects/modules
if (pass == 'P'){
count++;
}

totalCred = totalCred + credits;

Cols++;
}


//Setting of counting of number of passed subjects here.
S[Rows].setCount(count);






Rows++;


}
}

inFile.close();

DA: http://www.pohcbsonic.deviantart.com/
Blog: http://www.pohcbsonicx.blogspot.com/
Homepage: http://www.pohcbsonic.tripod.com/

modified on Tuesday, April 21, 2009 12:42 AM