Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Need Help On Homework

Reply
Thread Tools

Need Help On Homework

 
 
Allens Mail
Guest
Posts: n/a
 
      07-13-2003
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****************************************** **


 
Reply With Quote
 
 
 
 
Aggro
Guest
Posts: n/a
 
      07-14-2003
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Java homework bd Java 7 11-12-2006 06:32 PM
Re: I need help with my homework!! Emergency!!! Karl Heinz Buchegger C++ 1 11-23-2004 05:06 PM
Re: I need help with my homework!! Emergency!!! Mike C++ 1 11-23-2004 04:05 AM
Need some help for some perl homework.... Perl 0 02-25-2004 01:45 AM
need help with homework Rhino Java 1 11-16-2003 06:52 PM



Advertisments