423,846 Members | 2,048 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,846 IT Pros & Developers. It's quick & easy.

hi,i need to create a program that reads grades from external file and calculte the a

P: 2
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
int average(){
if(str[a]=="A")
{
score = 4.00;
}
if(str[a]=="A-")
{
score=3.67;

}
if(str[a]=="B+")
{
score=3.33;
}
if(str[a]=="B")
{
score=3.00;
}
if(str[a]=="B-")
{
score=2.67;
}
if(str[a]=="C+")
{
score=2.33;
}
if(str[a]=="C")
{
score=2.00;
}
if(str[a]=="C-")
{
score=1.67;
}
if(str[a]=="D+")
{
score=1.33;
}
if(str[a]=="D")
{
score=1.00;
}
if(str[a]=="D-")
{
score=0.67;
}
if(str[a]=="F")
{
score=0.00;
}











}
int main()

{
int sem[60];
string name[60]="";
int unit[60];
string str[60];
int a=0;
int number;
string matric;
float score;

ifstream inputFile;
ofstream tnputFile;
inputFile.open("result.txt");

if(!inputFile)
{
cout<<"Error opening file"<<endl;
system("pause");
return 1;
}

while(!inputFile.eof() && a<60)
{


inputFile>>sem[a]>>name[a]>>unit[a]>>str[a];

a++;

}
inputFile.close();
number=a;

for(a=0;a<number;a++)
{


cout<<sem[a]<<"\t"<<name[a]<<"\t"<<unit[a]<<"\t"<<str[a]<<endl;

}




return 0;
}
1 Week Ago #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.