create a class GradeAverage with

February 2, 2010 at 21:48:41
Specs: Windows XP
create a class GradeAverage with ATTRIBUTES of subGrade and numUnits as data members and member function that calculates the GPA of a student in a semester. with float subGrade, float numUnits, string studName, string sudNumber.

See More: create a class GradeAverage with

Report •


#1
February 2, 2010 at 23:17:43
I'm not really a fan of C++, so take it for what you will. :P

the member function gpa is up to you... I don't know what is required to get an answer, or what (if anything) the function should return or accept as arguments.

to play around with, I created three objects - the default, supplied arguments, and an array.

#include <iostream>
#include <string>

using namespace std;  

class GradeAve {

   public : 
      GradeAve(const string &a = "", const string &b = "",
               const float &c = 0.0f, const float &d = 0.0f) { 
               
                  name = a;
                  id = b;
                  numUnits = c;
                  subGrade = d; }

      void showMembers() const { 
         cout << "Name: "
              << name << endl
              << "ID: "
              << id << endl
              << "numUnits: "
              << numUnits << endl
              << "SubGrade: " 
              << subGrade << endl; }

      float GPA(/* add any parameter list */) {
             // add function definition
            
            return (/* return function result */ 0.0f); }
                  

   private : float numUnits;
             float subGrade;
             string name;
             string id;
};

int main(void){

   GradeAve test1, test2("ima student", "000000", 12.5f, 1.5f),
            test3[3];

   test1.showMembers();
   cout << endl;
   test2.showMembers();
   cout << endl;

   for(int i=0; i < sizeof(test3) / sizeof(test3[0]); i++) {
      cout << "default params for rec [" << i << "]" << endl;
      test3[i].showMembers();
      cout << endl;
   }

   return 0;
}

HTH


Report •
Related Solutions


Ask Question