Total newbie to programming. I can't figure out why this error is claiming LettGrade is undeclared. I have it declared. Help please!
Heres the program:
#include <iostream.h>
#include <fstream.h
void main()
{
float score = (float)0.0; converted to a float.
char LettGrade = ' '; variable.
ifstream inFile;
inFile.open("a:/stuScr.dat",ios::in);
if(!inFile.fail())
{
outFile.open("a:/LettGrad.out",ios:
ut);
if(!outFile.fail())//This tests if the outFile did not fail to open.
{
inFile >> score;
while(!inFile.eof())
{
if(score>= 89.5)
LettGrad='A';
else
if(score>=79.5)
LettGrad='B';
else
if(score>=69.5)
LettGrad='C';
else
if(score>=59.5)
LettGrad='D';
else
LettGrad='F';
outFile << LettGrad << endl;
inFile >> score;
}//end while
//close outFile and inFile
outFile.close();
inFile.close();
cout<<"Program Completed"<<endl;
}
else
cout<<"Error opening output file"<<endl;
} else
cout<<"Error opening input file"<<endl;
}//End of main function
Heres the program:
#include <iostream.h>
#include <fstream.h
void main()
{
float score = (float)0.0; converted to a float.
char LettGrade = ' '; variable.
ifstream inFile;
inFile.open("a:/stuScr.dat",ios::in);
if(!inFile.fail())
{
outFile.open("a:/LettGrad.out",ios:
if(!outFile.fail())//This tests if the outFile did not fail to open.
{
inFile >> score;
while(!inFile.eof())
{
if(score>= 89.5)
LettGrad='A';
else
if(score>=79.5)
LettGrad='B';
else
if(score>=69.5)
LettGrad='C';
else
if(score>=59.5)
LettGrad='D';
else
LettGrad='F';
outFile << LettGrad << endl;
inFile >> score;
}//end while
//close outFile and inFile
outFile.close();
inFile.close();
cout<<"Program Completed"<<endl;
}
else
cout<<"Error opening output file"<<endl;
} else
cout<<"Error opening input file"<<endl;
}//End of main function
