Mathematics Report
Posted by JanWan
Last Updated: March 08, 2013
  2372

A program is required to read and print a series of name and exam scores for students enrolled in mathematics course. The class average is to be calculated and printed at the end of the report. Scores can range from 0 to 100. The last record contains a blank name and a score of 999 and is not to be included in the calculations.
   
  
 
 
   

 
 
Screen Shot

 
This is a demo version for the Mathematics Report program. The code will be post soon.
 
Here is my version of the code; I have a problem getting in a blank name because cin don't accept  empty string. but never the less here is my code.

#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string name;
int grade = 0;
int i = 0;
int sum = 0;
int average = 0;
for(;;)
{
  
  cout<<endl<<"Enter Student's name: ";
       cin>>name;
       
      cout<<"Enter Student's Grade: ";
       cin>>grade;
       
       
       if(grade == 999)
       break;
       i++;
        sum = sum + grade;

}
   average = sum/i;

cout<<endl<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl;
cout<<"Class Average: "<<average<<endl;
cout<<endl<<"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl;


return 0;
}
 
Demo version code

#include <iostream>
#include <string>
#include <stdio.h>
#include <conio.h>

using namespace std;

int main()
{
    int counter = 0;
    int Num_Student[counter];
    int Score = 0;
    string name;
    int Sum = 0;
    int  Average = 0;
    
    cout<<"\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl
        <<"\t\t\t@@\t\t\t  @@"<<endl
        <<"\t\t\t@@ \tMATHEMATICS \t  @@"<<endl
        <<"\t\t\t@@ \t  REPORT    \t  @@"<<endl
        <<"\t\t\t@@\t\t\t  @@"<<endl
        <<"\t\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@"<<endl<<endl;                                
    
    cout<<"Amount of student: ";
    cin>>counter;
    cout<<endl;
    
    for(int i = 0; i < counter; i++)
    {
        cout<<"Enter Student Name: ";
        Num_Student[i];
        cin>>name;
        cout<<"Enter grade: ";
        cin>>Score;
        cout<<endl;
        
        Sum = Sum + Score;
        Average = Sum/counter;
    }
    
    cout<<"The Overall Average is: "<<endl
    <<"*************************"<<endl
    <<"\t"<<Average<<endl
    <<"*************************";
    cout<<endl;

    return 0;
}

 
Richard, use Samath version of the program. It fulfill the requirement of what the question ask for.