Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Need Help On Homework (http://www.velocityreviews.com/forums/t268298-need-help-on-homework.html)

Allens Mail 07-13-2003 10:20 PM

Need Help On Homework
 
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****************************************** **



Aggro 07-14-2003 05:52 AM

Re: Need Help On Homework
 
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.



All times are GMT. The time now is 10:18 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57