help me!

i put in this code, and got errors on my else ifs. i have looked through everything and cant find the answer to my question! please help!

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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  #include<iostream>;
#include<string>;

using std::cin;
using std::cout;
using std::string;
using std::endl;

int main()
{
	//Grade Point Average

	double grade1 = 0.0;
	double grade2 = 0.0;
	double grade3 = 0.0;
	double grade4 = 0.0;
	double grade5 = 0.0;
	double grade6 = 0.0;
	double grade7 = 0.0;
	double grade8 = 0.0;
	double grade9 = 0.0;
	double grade10 = 0.0;
	double gpa = 0.0;
	bool numOfGrades = true;

	cout << "How many grades do you have?: ";
	cin >> numOfGrades;

	if (numOfGrades = 1);
	{
		cout << "Dont even ask, its the same number you would type in.";
		return 0;
	}
	else if (numOfGrades = 2);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		gpa = (grade1 + grade2) / 2;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 3);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		gpa = (grade1 + grade2 + grade3) / 3;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 4);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		gpa = (grade1 + grade2 + grade3 + grade4) / 4;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 5);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5) / 5;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 6);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6) / 6;
		cout << "Your GPA is: " << gpa << endl;

		return 0;
	}
	else if (numOfGrades = 7)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;

		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7) / 7;
		cout << "Your GPA is: " << gpa << endl;

		return 0;
	}
	else if (numOfGrades = 8);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;
		cout << "What is your eighth period grade? type in percentage: ";
		cin >> grade8;


		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8) / 8;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 9);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;
		cout << "What is your eighth period grade? type in percentage: ";
		cin >> grade8;
		cout << "What is your ninth period grade? type in percentage: ";
		cin >> grade9;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8 + grade9) / 9;
		cout << "Your GPA is: " << gpa << endl;

		return 0;
	}
	else if (numOfGrades = 10);
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;
		cout << "What is your eighth period grade? type in percentage: ";
		cin >> grade8;
		cout << "What is your ninth period grade? type in percentage: ";
		cin >> grade9;
		cout << "What is your tenth period grade? type in percentage: ";
		cin >> grade10;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8 + grade9 + grade10) / 10;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
}
Remember there's a difference between the assignment operator = and checking for equality with ==.

The if/else if clauses do not need a semi-colon. (Nor do the include statements)

Also - if you're expecting someone to enter a number in numOfGrades, I'm wondering why it was declared as a bool type?
Is this better? all it does is the first command with "1",
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#include<iostream>
#include<string>

using std::cin;
using std::cout;
using std::string;
using std::endl;

int main()
{
	
	//Grade Point Average

	double grade1 = 0.0;
	double grade2 = 0.0;
	double grade3 = 0.0;
	double grade4 = 0.0;
	double grade5 = 0.0;
	double grade6 = 0.0;
	double grade7 = 0.0;
	double grade8 = 0.0;
	double grade9 = 0.0;
	double grade10 = 0.0;
	double gpa = 0.0;
	double numOfGrades = 0.0;

	cout << "How many grades do you have?: ";
	cin >> numOfGrades;

	if (numOfGrades = 1)
	{
		cout << "Dont even ask, its the same number you would type in.";
		return 0;
	}
	else if (numOfGrades = 2)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		gpa = (grade1 + grade2) / 2;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 3)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		gpa = (grade1 + grade2 + grade3) / 3;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 4)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		gpa = (grade1 + grade2 + grade3 + grade4) / 4;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 5)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5) / 5;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 6)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6) / 6;
		cout << "Your GPA is: " << gpa << endl;

		return 0;
	}
	else if (numOfGrades = 7)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;

		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7) / 7;
		cout << "Your GPA is: " << gpa << endl;

		return 0;
	}
	else if (numOfGrades = 8)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;
		cout << "What is your eighth period grade? type in percentage: ";
		cin >> grade8;


		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8) / 8;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
	else if (numOfGrades = 9)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;
		cout << "What is your eighth period grade? type in percentage: ";
		cin >> grade8;
		cout << "What is your ninth period grade? type in percentage: ";
		cin >> grade9;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8 + grade9) / 9;
		cout << "Your GPA is: " << gpa << endl;

		return 0;
	}
	else if (numOfGrades = 10)
	{
		cout << "What is your first period grade? type in percentage: ";
		cin >> grade1;
		cout << "What is your second period grade? type in percentage: ";
		cin >> grade2;
		cout << "What is your third period grade? type in percentage: ";
		cin >> grade3;
		cout << "What is your fourth period grade? type in percentage: ";
		cin >> grade4;
		cout << "What is your fifth period grade? type in percentage: ";
		cin >> grade5;
		cout << "What is your sixth period grade? type in percentage: ";
		cin >> grade6;
		cout << "What is your seventh period grade? type in percentage: ";
		cin >> grade7;
		cout << "What is your eighth period grade? type in percentage: ";
		cin >> grade8;
		cout << "What is your ninth period grade? type in percentage: ";
		cin >> grade9;
		cout << "What is your tenth period grade? type in percentage: ";
		cin >> grade10;
		gpa = (grade1 + grade2 + grade3 + grade4 + grade5 + grade6 + grade7 + grade8 + grade9 + grade10) / 10;
		cout << "Your GPA is: " << gpa << endl;
		return 0;
	}
}
if (numOfGrades = 1)

You're assigning the value of 1 to numOfGrades here, you're not checking to see if it's equal to 1.
use == instead of =
Last edited on
thank you so very much
Topic archived. No new replies allowed.