Answer:
See Explaination
Step-by-step explanation:
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <sstream>
using namespace std;
float compute(float mark1,float mark2){
return mark1/mark2*100;
}
void printPercent(string name,float mark1,float mark2){
float percent;
percent=compute(mark1,mark2);
int percentWhole;
percentWhole = ceil(percent);
cout<<name<<" "<<percentWhole<<"% "<<percent;
if(percent>90){
cout<<" Excellent";
}else if(percent>80){
cout<<" Well Done";
}else if(percent>70){
cout<<" Good";
}else if(percent>60){
cout<<" Need Improvement";
}else if(percent<60){
cout<<" Fail";
}
cout<<endl;
}
void processFile(char fileName[20]){
ifstream infile;
string line;//for read line
cout<<"Loading the file........"<<fileName<<endl;
cout<<"File scan done........"<<endl;
infile.open (fileName);
string name;
float mark1,mark2;
if (infile.is_open())
{
while( infile>>name>>mark1>>mark2 ) {
printPercent(name,mark1,mark2);
}
infile.close(); //close file
}
else //if file not found show the below message
{
cout << "Sorry, we could not find the file." << endl;
}
}
int main( )
{
cout << fixed << showpoint << setprecision(3);
string line;//for read line
cout<<"Loading the file........"<<endl;
char fileName[20];
cout<<"Enter file name : ";
cin>>fileName;
processFile(fileName);
return 0;
}