hello someone out there...help me with algorithm to determine range of marks!!
here is my code so far
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
struct stumarks
{
int studentid;
int progassn;
int lab;
int test;
int exam;
char seperator;
double finalmark;
}
stumarks[9];
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open("datafile.txt");
if (!inFile)
{
cout << "Cannot open input file. "
<< "Program terminates!" << endl;
return 1;
}
outFile.open("datafile.out");
int i;
inFile >>stumarks[i].studentid >>stumarks[i].seperator>>stumarks[i].progassn
>>stumarks[i].seperator>>stumarks[i].lab
>>stumarks[i].seperator
>>stumarks[i].test>>stumarks[i].seperator
>>stumarks[i].exam;
/* while (inFile)
{
cout <<stumarks[i].studentid<<' '
<<stumarks[i].progassn<<' '
<<stumarks[i].lab<<' '
<<stumarks[i].test<<' '
<<stumarks[i].exam<<endl;
inFile >>stumarks[i].studentid >>stumarks[i].seperator>>stumarks[i].progassn
>>stumarks[i].seperator>>stumarks[i].lab
>>stumarks[i].seperator
>>stumarks[i].test>>stumarks[i].seperator
>>stumarks[i].exam;
} */
cout<<endl;
cout<<"\n\n\n\n";
outFile << endl;
cout<<"\t"<<setw(10)<<"ProgaAssn"<<"\t"<<"Lab"<<setw(3)<<"\t"<<"Test"<<"\t"<<"Exam"<<endl;
const int arraysize=11;
int grade[arraysize]={stumarks[i].studentid,stumarks[i].progassn,stumarks[i].lab,stumarks[i].exam};
for (int j=0; j<arraysize; j++)
{
inFile >>stumarks[i].studentid >>stumarks[i].seperator>>stumarks[i].progassn
>>stumarks[i].seperator>>stumarks[i].lab
>>stumarks[i].seperator
>>stumarks[i].test>>stumarks[i].seperator
>>stumarks[i].exam;
if(j>0||j<19){
cout<<"0-19";
break;}
if (j>19||j<39){
cout<<"20-39";
break;}
if (j>39 || j<59){
cout<<"40-59";
break;}
if (j>59 || j<79){
cout<<"60-79";
break;}
if (j>79 || j<=100){
cout<<"80-100";
break;}
}
cout<<endl;
cout<<"\n\n\n";
cout<<setw(4)<<"ID"
<<" "<<"ProgAssn"
<<" "<<"LabExer"
<<" "<<"Test"
<<" "<<"Exam"
<<" "<<"Final Mark"<<endl;
while(inFile)
{ stumarks[i].finalmark=(stumarks[i].progassn*0.1+stumarks[i].lab*0.1+stumarks[i].test*0.2+stumarks[i].exam*0.6);
cout <<stumarks[i].studentid<<' '
<<" "<<stumarks[i].progassn
<<" "<<stumarks[i].lab
<<" "<<stumarks[i].test
<<" "<<stumarks[i].exam
<<" "<<setprecision(2)<<stumarks[i].finalmark<<endl;
inFile >>stumarks[i].studentid >>stumarks[i].seperator>>stumarks[i].progassn
>>stumarks[i].seperator>>stumarks[i].lab
>>stumarks[i].seperator
>>stumarks[i].test>>stumarks[i].seperator
>>stumarks[i].exam;
}
inFile.close();
outFile.close();
system("pause");
return 0;
}
my problem is to ouput the range of marks between 0-19,20-39, xtra...
i can't figure out the algorithm... it bother me since yesterday...i can't help it...teach me...range of marks algotrithm....
oh yeah. the data file is as follows:
123451,66,75,70,80
123452,39,22,35,55
123453,5,5,20,30
123454,45,33,48,70
123455,77,85,60,40
123461,90,86,88,96
123462,80,90,80,85
123463,55,63,58,65
should be 50 students but i just minimize it to 8 so that i could see the way this program works....all explaination and help are welcome...and don't give me da direct code....