Help with GPA calculator problem

Hi, I keep getting a red squiggly line under my "<<" symbols and I don't know why!!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<ctime>
#include<iostream>
#include<string>
using namespace std;
int main(void) {
	int numClass=0; //user's number of classes
	int numCred=0; //user's number of credits
	int numGrade=0; //user's numeric value for grade
	int numSem=0; //user's amount of semesters
	float semGPA=0; //user's gpa at the end of each semester
	float cumGPA=0; //user's cumuilitive GPA
	do {
		cout << "Number of classes taken?"<<endl;
				cin << numClass;
		cout << "How many credits total?" << endl;
				cin <<  numCred;
		cout<< "How many semesters have you taken?"<< endl;
			cin << numSem; 
cin is like this: cin >>

you are doing cin <<
D'oh! Simple mistake!

Now my only question is why am I getting an error under the first "if" it says "expected a '('"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
if{
					((grade=='a')||(grade=='A'))
						(grade=4);
						else
								if ((grade=='b')||(grade=='B'))
									(grade=3);
								else
									if ((grade=='c')||(grade=='C'))
										(grade=2);
									else
										if ((grade=='d')||(grade=='D'))
											(grade=1);
										else
											(grade=0);}	
Last edited on
first you must put the comparison and then the bracket for instructions.

like this If(comparison) {instruction}

You used a Bracket right after the if.

also why are you putting the comparison in two different sets of parenthesis. Cant you do it like this.

Also I notice your using the variable ...grade..... for both the comparison and the input instruction....might want to change the input to something like ...Grade..with a capital G...or ....gradeValue...

if (grade=='a' || grade == 'A') { grade =4};
else if (grade=='b' || grade == 'B') { gradeValue = 3}

Hope this helps
Topic archived. No new replies allowed.