Need Help On Homework

Discussion in 'C++' started by Allens Mail, Jul 13, 2003.

  1. Allens Mail

    Allens Mail Guest

    Help,
    Due Mon
    I cant find the error. Keeps saying illegal token } have gone though code
    and balance all French braces and parenthesis. Please help going crazy.
    Code below
    Thanks
    Allen

    //**************************************************************************
    *******
    // This program calculates your GPA for grades that are entered for a
    unknown *
    // number of classes for a student. GPA is calculated by taking the grade
    value *
    // times the unit value to get points. Points and units are running totals
    *
    // A grade of Q will end the program and the GPA is calculated by dividing
    the *
    // total number of points divided by total number os units. *
    //**************************************************************************
    *******

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

    void main(void)
    {

    int GetGrade(int gradePoints);
    float GetUnits(float uVal);

    //Declaration programmer information
    const char MY_NAME[25]= "Allen Mecum"; //progrqammer name
    const char SECTION[25]= "CIS 1A M W 8-11:35am"; //class section
    const char DATE[11]="07/02/2003"; //current date
    const char DUEDATE[11]="07/07/2003"; //due date

    // User Enters Grade and Units for class.
    cout << "\nName: "<<MY_NAME << "\n";
    cout << "Section: " << SECTION << "\n";
    cout << "Date: " << DATE << "\n";
    cout << "Due date:" << DUEDATE << "\n\n\n";

    //GetGradeVal*UnitVal=totalPoints
    cout << GetGrade << " and " << GetUnits;
    }

    //*********************************END
    MAIN*************************************************

    //Void Function GetGrade obtains input from the user and checks to see that
    it is valid.
    //It continues to prompt the user for a letter grade while the grade entered
    is not
    //an A, B, C, D, F or Q.

    int GetGrade(int gradePoints)
    {
    char grade;


    const int GRADEA=4;
    const int GRADEB=3;
    const int GRADEC=2;
    const int GRADED=1;
    const int GRADEF=0;


    do
    {
    cout << "Please enter you grade (A-F, 'Q' to quit):";
    cin >> grade;

    gradePoints=0; // resets Temp locations to 0

    switch(grade)
    {
    case 'a' :
    case 'A' : gradePoints=GRADEA;
    break;
    case 'b' :
    case 'B' : gradePoints=GRADEB;
    break;
    case 'c' :
    case 'C' : gradePoints=GRADEC;
    break;
    case 'd' :
    case 'D' : gradePoints=GRADED;
    break;
    case 'f' :
    case 'F' : gradePoints=GRADEF;
    break;
    case 'q' :
    case 'Q' : gradePoints=0;
    break;
    default : cout<<"***** INVAILD ENTRY *****\n\n";
    break;
    }

    }
    while (grade!='Q' && grade!='q');
    return gradePoints;
    }
    //***********************************END
    GetGrade****************************************

    //Void Function GetUnits obtains from the user and checks to see that it is
    vailid.
    //It continues to prompt the user for a unit valuse while the units are not
    in
    //the range 0.0-9.0

    float GetUnits(float uVal)
    {

    do
    {
    cout << "Enter the unit value:";
    cin >> uVal; //stores temp units for calculation

    if (uVal<0.0 || uVal> 9.0)
    {
    cout<<"Invaild Entry";
    }
    else
    {
    return uVal;
    }
    }
    }
    //*************************************END
    GetUnits********************************************
    Allens Mail, Jul 13, 2003
    #1
    1. Advertising

  2. Allens Mail

    Aggro Guest

    Allens Mail wrote:

    > #include <iostream>
    > #include <iomanip>
    > using namespace std;
    >
    > void main(void)


    int main()

    > {
    >
    > int GetGrade(int gradePoints);
    > float GetUnits(float uVal);


    These should be outside main(). And before it also. Move these two lines
    between "using namespace std;" and "int main()" and you should be ok

    < Some code removed here >

    > float GetUnits(float uVal)
    > {
    >
    > do


    Try this instead of do:

    while(1)

    > {
    > cout << "Enter the unit value:";
    > cin >> uVal; //stores temp units for calculation
    >
    > if (uVal<0.0 || uVal> 9.0)
    > {
    > cout<<"Invaild Entry";
    > }
    > else
    > {
    > return uVal;
    > }
    > }
    > }


    I didn't check if anything else is wrong in the code. Just fixed it so
    it would compile.
    Aggro, Jul 14, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    0
    Views:
    670
    Guest
    Feb 25, 2004
  2. Rhino

    need help with homework

    Rhino, Nov 16, 2003, in forum: Java
    Replies:
    1
    Views:
    301
    Roedy Green
    Nov 16, 2003
  3. Mike
    Replies:
    1
    Views:
    322
    Phlip
    Nov 23, 2004
  4. Karl Heinz Buchegger

    Re: I need help with my homework!! Emergency!!!

    Karl Heinz Buchegger, Nov 23, 2004, in forum: C++
    Replies:
    1
    Views:
    383
    Raymond Martineau
    Nov 23, 2004
  5. bd
    Replies:
    7
    Views:
    540
    Daniel Pitts
    Nov 12, 2006
Loading...

Share This Page