I can't seem to get it working properly. Here's what I have thus far.

#include <string>
#include <iostream>



class Student_t
{
     char firstName[20];                        //to hold the first name
     char lastName[20];                         //to hold the last name
     int exam1;                                 //to hold Exam-1-Grade
     int exam2;                                 //to hold Exam-2-Grade
     int homeworkavg;                            //to hold Homework-Average
     double average;                            //to hold the Fina-Exam-Grade
     char grade[2];                                //to hold the students letter 

public:
    static int numStudents;
    static int innerCount;
     void ReadRecord();
    void CalculateGrade();
     void WriteRecord();
     void ReportSummary();
};
int Student_t::numStudents=0;
int Student_t::innerCount=0;  
//ReadRecord's function is to read in all of the individual
//Students information and exam grades and store in student_t
void Student_t::ReadRecord()
 {
          cout << "Please enter student first name:";
          cin >> firstName;
          cout << "Please enter student last name:";
          cin >> lastName;
          cout << "Please enter student first exam score <max 10>:";
          cin >> exam1;
          cout << "Please enter student second exam score <max 10>:";
          cin >> exam2;
          cout << "Please enter student Homework Average: ";
          cin >> homeworkavg;
          cout << "The Student's Average is:  ";
          cin >> average;

          cin >> average;
            numStudents++;
 }
//CalculateGrade's function is to determine the letter grade
//and average grade for the student 
void Student_t::CalculateGrade()
 {
        double avg=0;
         avg = (exam1*.2)+(exam2*.2)+(homeworkavg*.35)+(.25*average);
        average = avg;                                    //send average
         if(avg >= 90)strcpy(grade,"A");                 //assign letter grade
         else if(avg >= 80)strcpy(grade,"B");
         else if(avg >= 70)strcpy(grade,"C");
         else if(avg >= 60)strcpy(grade,"D");
         else strcpy(grade,"F");
 }
//WriteRecord's function is to display all the gathered information on 
//the screen after the averages and letter grades have been assigned
void Student_t::WriteRecord()
 {
        cout << firstName << "\t";
          cout << lastName << " \t";
          cout << exam1 << " \t";
          cout << exam2 << " \t";
          cout << homeworkavg << " \t";
          cout << average << " \t";
        cout << grade << " \t";

     //return 0;
 }

int main(int argc, char* argv[])
{
     Student_t Students[20];
     //int StudentCount = 0;
     Student_t::numStudents = 0;
     int iNo;
EnterNumberOfStudents:
     cout<<"Enter No of Students between(0 to 20): Enter 0 to Exit";
     cin>>iNo;
     if(!(iNo >= 0 && iNo <= 20))
          goto EnterNumberOfStudents;


     for(int j=0; j<iNo; j++)
     {
          Students[j].ReadRecord();
     }


     if(Student_t::numStudents > 0)
          cout << "Sr.No\tFirst Name\tLast Name\tExam #1 Grade\tExam #2 Grade\tHomework Average\tFinal Grade\tGrade\n";

     for(j=0; j<Student_t::numStudents; j++)
     {
          Students[j].CalculateGrade();
          cout<<j+1 << "\t";
          Students[j].WriteRecord();
          cout<<"\n";
     }

     return 0;
}

Edited 3 Years Ago by Nick Evan: Fixed formatting

Ok, this is what I have so far. It compiles, It runs but it asks for the Average and that is the one thing I want it to figure out and input it into itself.

#include <iostream>
#include <string>
using namespace std;


class Student_t
{
     char firstName[20];                        //to hold the first name
     char lastName[20];                         //to hold the last name
     int exam1;                                 //to hold Exam-1-Grade
     int exam2;                                 //to hold Exam-2-Grade
     int homeworkavg;                           //to hold Homework-Average
     double average;                            //to hold the Fina-Exam-Grade
     char grade;                                //to hold the students letter 

public:
    static int numStudents;
    static int innerCount;
    void ReadRecord();
    void CalculateGrade();
    void WriteRecord();
    void ReportSummary();
};
int Student_t::numStudents=0;
int Student_t::innerCount=0;  
//ReadRecord's function is to read in all of the individual
//Students information and exam grades and store in student_t
void Student_t::ReadRecord()
 {
cout << "Please enter Students First Name: ";
          cin >> firstName;
          cout << "Please enter student Last name: ";
          cin >> lastName;
          cout << "Please enter the students First Exam score: ";
          cin >> exam1;
          cout << "Please enter the students Second Exam score: ";
          cin >> exam2;
          cout << "Please enter the students Homework Average: ";
          cin >> homeworkavg;
          cout << "The Students Average is: " << average << " \n";
          cin >> average;

          numStudents++;
 }
//CalculateGrade's function is to determine the letter grade
//and average grade for the student 
void Student_t::CalculateGrade()
 {
        double avg=0;
        avg = (exam1*.2)+(exam2*.2)+(homeworkavg*.35)+(.25*average);
        average = avg;                            //send average
         if(avg >= 90)grade='A';                 //assign letter grade as a *single* character
         else if(avg >= 80)grade='B';
         else if(avg >= 70)grade='C';
         else if(avg >= 60)grade='D';
         else grade='F';
 }
//WriteRecord's function is to display all the gathered information on 
//the screen after the averages and letter grades have been assigned
void Student_t::WriteRecord()
 {
          cout << firstName << "\t";
          cout << lastName << " \t";
          cout << exam1 << " \t";
          cout << exam2 << " \t";
          cout << homeworkavg << " \t";
          cout << average << " \t";
          cout << grade << " \t";

     //return 0;
 }

int main(int argc, char *argv[])
{
     Student_t Students[20];
     //int StudentCount = 0;
     Student_t::numStudents = 0;
     int iNo;
     EnterNumberOfStudents:
     cout<<"Enter No of Students between(0 to 20): Enter 0 to Exit";
     cin>>iNo;
     if(!(iNo >= 0 && iNo <= 20))
          goto EnterNumberOfStudents;


     for(int j=0; j<iNo; j++)
     {
          Students[j].ReadRecord();
     }


     if(Student_t::numStudents > 0)
          cout << "Sr.No\tFirst Name\tLast Name\tExam #1 Grade\tExam #2 Grade\tHomework Average\tFinal Grade\tGrade\n";

     for(int j=0; j<Student_t::numStudents; j++)
     {
          Students[j].CalculateGrade();
          cout<<j+1 << "\t";
          Students[j].WriteRecord();
          cout<<"\n";
     }

system("pause");             //this line was added to cause the screen to pause

     return 0;
}

Edited 3 Years Ago by pyTony: fixed formatting

Well, without reading any further, delete those goto's!! Your instructor will probably remove credit for using goto. use while() or do - while() instead.

and please surround code with [ code ] and [ /code ] (remove spaces between brackets. That will make your code easier for others (and me) to read.

Did I not do this correctly?

int main(void)
{
finalgrade Students[20];
//int StudentCount = 0;
finalgrade::numStudents = 0;
int iNo;
EnterNumberOfStudents:
cout<<"Enter No of Students between(0 to 20): Enter 0 to Exit: ";
cin>>iNo;
Do{
EnterNumberOfStudents;
}
while (!(iNo >= 0 && iNo <= 20))
for(int j=0; j<iNo; j++)
{ Students[j].ReadRecord();
}

>>Did I not do this correctly?

what did your compiler say about it? (you forgot to put a semicolon at the end of the while statement. ) You might also add an error message inside the loop so that you don't wounder by the program won't accept the keyboard input.

In function `int main()':

83 `Do' undeclared (first use this function)

83 expected `;' before '{' token

Are the errors I'm receiving.

In function `int main()':

83 `Do' undeclared (first use this function)

83 expected `;' before '{' token

Are the errors I'm receiving.

"do" is case sensitive.. you used a capital letter D.

Doh!

Ok, It looks as though I only have one more error to work around.

84 'EnterNumberOfStudents' undeclared (first use this function)

do{
EnterNumberOfStudents;
}while (!(iNo >= 0 && iNo <= 20));
for(int j=0; j<iNo; j++)
{
Students[j].ReadRecord();
}

Doh!

Ok, It looks as though I only have one more error to work around.

84 'EnterNumberOfStudents' undeclared (first use this function)

do{
EnterNumberOfStudents;
}while (!(iNo >= 0 && iNo <= 20));
for(int j=0; j<iNo; j++)
{
Students[j].ReadRecord();
}

EnterNumberOfStudents was your goto tag wasn't it? the compiler is telling you that it doesn't exist (because you've sensibly decided not to use the dreaded 'goto')

from your original code, I believe this is what you wanted to put inside your do-while loop...

cout<<"Enter No of Students between(0 to 20): Enter 0 to Exit";
cin>>iNo;

That was exactly the problem. Thank you so much.

When I run the program it's giving me

Final Grade: 1.11199e+292

And then that's it. So even though it's compiling now, I don't think it's doing what is intended.

I'll keep plugging at it and see if I can come up with something.

This article has been dead for over six months. Start a new discussion instead.