I need to write a program in C++ that will compute numeric grades for a course. The course records are in a file that will serve as the input file.Each line will have a last name, first name, ten quizes all on one line...

you should calculate the average and standard deviation of the grades;;;

we dont do your homework, we only help when you show effort.

when i enter a file name, the program is terminating before it does anything...

Here is the program......

#include <iostream> 
#include <fstream> 
#include <cstdlib> 
#include <ctype.h> 
using namespace std;

void calc_grade(ifstream& ins, ofstream& outs); 
bool isscore(ifstream& ins); 

int main()
{ 
  char file1[12], file2[12]; 
  ifstream ins; 
  ofstream outs; 

   cout << "Enter the name of input file: "; 
   cin >> file1; 
   ins.open(file1); 
   if (ins.fail()) 
   { 
        cout << "Input file could not be opened"<<endl; 
        exit(1); 
   } 

    cout << "Enter the name of output file: "; 
    cin >> file2; 
    outs.open(file2); 
           if (outs.fail()) 
   { 
          cout << "Output file could not be opened"; 
     exit(1); 
} 

calc_grade(ins, outs); 

ins.close(); 
outs.close(); 

cout << "End of program.\n"; 
} 

bool isscore(ifstream& ins) 
{ 
     char next; 
     ins.get(); 
     next=ins.peek(); 
     return isdigit(next); 
  }

void calc_grade(ifstream& ins, ofstream& outs) 
{ 
    char lname[20], fname[15]; 

   while (!ins.eof())
   { 
   int score, total=0, count=1; 
   ins >> lname >> fname; 

outs << lname << " " << fname << " " ; 
    while (count<11 && isscore(ins)) 
	{ 
    ins >> score; 
    count++; 
    total+=score; 
    outs.width(4); 
    outs << score; 
 } 

   outs <<" " <<(double(total)/10) << endl; 
  } 
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.