Calculating grade averages

I'm trying to get this program to calculate the grade average of 25 kids but now I just got stuck with the calculating the average part

what did I do wrong here

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

#include <iostream>
#include <string>

using namespace std;

int main()
{
	//step 1: Declare variables
	string firstname = " ";
	float avg=0, grade1=0, grade2=0, grade3=0;
	char finalGrade = 'F';
	int studentCount=0;
	double Average = (grade1+grade2+grade3)/3;
	int 90-100=A, 80-89.9=B, 70-79.9=C, 60-69.9=D, 0-59.9=F; 

	//step 2: Design the loop to process students
	for(int studentCount=1; studentCount<=25; studentCount=studentCount+1)
	{
	  
		//step 3a: Get the input
		cout<<"Please Enter Grade #1"<<endl;
		cin >> grade1 ;
		cout<<"Please Enter Grade #2"<<endl;
		cin >> grade2 ;
		cout<<"Please Enter Grade #3"<<endl;
		cin>> grade3 ;
		//step 3b: Calculate the average
		cout<<Average<<endl; 
		 

		//step 3c: Determine the letter grade

		//step 3d: Write the output
	}

	return 0;
}





I Know its something small
Thanks fellas!!! and know this isn't my HW.
closed account (zb0S216C)
First, grade1, grade2, grade3 are of type float, where, Average is of type double. This should not affect the code in a large way, however. Second, Average is computed before the user enters the grades. Calculate the grades after the user has entered the grades. Third, it's easier to write studentCount++ instead of studentCount=studentCount+1 in the for loop.

EDIT: int 90-100=A, 80-89.9=B, 70-79.9=C, 60-69.9=D, 0-59.9=F; is not valid. You cannot have identifiers beginning with numbers and you also cannot have identifiers which are computations. Instead, do this: int A( 90-100 ), B( 80-89.9 ), C( 70-79.9 ), D( 60-69.9 ), F( 0-59.9 );

Note: Any floating points that are assigned to a variable, which is of type int, are truncated.
Last edited on
Topic archived. No new replies allowed.