![]() |
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****************************************** ** |
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.