Thread: Hi some questions

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    Hi some questions

    Hi,

    I have some questions about a program in which we calculate a GPA(Grade Point Average).

    Eg.

    formula:
    GPA = Grade Point + Credit Hours;

    My program is :

    Code:
    class student
    {
    
    
    public:
    
    
    student(int Grade_Point,int Credit_Hour); //initializing the data members of the class using constructor/
    
    ~student(); // destructor of the class/
    
    
    void GetData();
    void CalculateGPA(); 
    void WriteData();
    
    
    private: 
    int Grade_Point; 
    int Credit_Hour ;
    
    GPA = Grade Point + Credit Hours; // formula used for calculating GPA(Grade Point Average)/
    
    
    
    };
    int main()
    {
    cout<<"Student GPA"; 
    
    int Grade_Point;
    int Credit_Hour;
    int GPA;
    
    
    system("pause");
    }
    -----------------------------------------------
    I wanted to know that can I declare arrays for GP and Credit Hours,so that they could be used in the formula for GPA calculation?

    Also pls let me know if I have correctly initalized the data members of the class using the constructor.


    My other question is that do I have to use "int" before main()?

    I hope I am clear
    Last edited by student111; 01-22-2012 at 08:27 AM.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    I wanted to know that can I declare arrays for GP and Credit Hours,so that they could be used in the formula for GPA calculation?
    Yes you can create arrays to hold the GP and Credit Hours and still use these variables in your calculation.
    Also pls let me know if I have correctly initalized the data members of the class using the constructor.
    Since you did not post the class implementation, I would say probably not.

    My other question is that do I have to use "int" before main()?
    Yes, and you should return an int from this function, usually zero.

    Also you GPA calculation looks incorrect. How do you determine a Grade Point? How do you determine an average?

    Jim

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    I always thought that grade point average was actually a quotient and not a sum, but that's just one of my crazy ideas.

  4. #4
    Registered User
    Join Date
    Nov 2011
    Posts
    96
    Hi,

    Thanks for your reply,so what do you mean by class implementation?

    If I also use "char" as a data type for any of these data members then still can I use "int" before the main()?

    Is "string" a data type?

    The formula for calculating GPA is GPA=GradePoint * CreditHour

  5. #5
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    If I also use "char" as a data type for any of these data members then still can I use "int" before the main()?
    The function main must be defined as a function returning an int, always.

    Isn't Grade Point Average an average of Grade Points? How do you compute the Grade Point? What is the definition of an Average? How do you compute an average?

    Thanks for your reply,so what do you mean by class implementation?
    See these links for Classes I and Classes II

    Is "string" a data type?
    Yes std::string is considered a data type.

    Jim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. please help me .. about the following questions
    By anggana in forum C Programming
    Replies: 4
    Last Post: 12-14-2010, 03:16 PM
  2. questions....so many questions about random numbers....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 07-30-2009, 08:47 AM
  3. A few questions
    By Shotgun in forum C Programming
    Replies: 4
    Last Post: 03-24-2006, 02:39 PM
  4. 2 STL questions
    By arjunajay in forum C++ Programming
    Replies: 4
    Last Post: 03-12-2006, 04:52 AM
  5. Various Questions
    By Stan100 in forum Game Programming
    Replies: 4
    Last Post: 05-08-2003, 02:09 AM