Average won't average

So I'm trying to create a program that will average together 5 grades and tell you how you are doing. It says I have no errors, but when I run the program doesn't prompt me to type in a grade or average. This is my first time every really doing this, and I am highly confused.




#include <iostream.h>



int main()
{

//declare variables


int name;
int grade;
int i;
int firstTest;
int secondTest;
int thirdTest;
int fourthTest;
int fifthTest;
int average;


cout << " Enter you name ." << endl;
cin >> name;
cout << " Enter the first test score: " << firstTest << endl;
cin >> firstTest;
cout << " Enter the second test score: " << secondTest << endl;
cin >> secondTest;
cout << " Enter the third test score: " << thirdTest << endl;
cin >> thirdTest;
cout << " Enter the fourth test score: " << fourthTest << endl;
cin >> fourthTest;
cout << " Enter the forth test score: " << fifthTest << endl;
cin >> fifthTest;


average = (firstTest + secondTest + thirdTest + fourthTest + fifthTest) / 5;



//cout << " The average of the five tests is: " << average << endl;


{



//Test average and class status

if (average >= 86 && average<= 100)
{
cout << " Your average is: " << average << endl; "Excellent ! Congratualtions ! "
; }
else if (average >= 85 && average <= 70)

cout << " Your average is: " << average << endl; " Fair ! "
;if (average <= 69)

cout << " Your average is: " << average << endl; " Poor ! "
;}

//finish up
cout << "Program will now terminate." << endl;



;}


Hey I added some tips in for your code. I still can't figure out why it doesnt prompt you sorry.
here are some tips anyways

// this part is hard to remember at first I am new and almost always forget namespace std
# include <iostream>
using namespace std;

int name;
int grade;
int i;
char wait;
// always initiliaze variables to avoid junk responses
int firstTest = 0 ;
int secondTest = 0;
int thirdTest = 0;
int fourthTest=0;
int fifthTest= 0;
int average = 0;


int main()
{

//declare variables




// I removed viewing your grade before you entered a value then made it display after
cout << " Enter you name ." << endl;
cin >> name;
cout << name << "please " << " Enter the first test score: " << endl;
cin >> firstTest;
cout << name << "please " << " Enter the second test score: " << "previous scores are " << firstTest << endl;
cin >> secondTest;
cout << name << "please " << " Enter the third test score: " << "previous scores are" << firstTest << secondTest<< endl;
cin >> thirdTest;
cout << name << "please " << " Enter the fourth test score: " << "previous scores are" << firstTest << secondTest<< thirdTest << endl;
cin >> fourthTest;
cout << name << "please " << " Enter the fifth test score: " << "previous scores are" << firstTest << secondTest<< thirdTest<< fourthTest << endl;
cin >> fifthTest;

cout << "your test scores were " << firstTest << secondTest<< thirdTest<< fourthTest<< fifthTest << endl;
average = (firstTest + secondTest + thirdTest + fourthTest + fifthTest) / 5;

cout << " The average of the five tests is: " << average << endl;





//Test average and class status

if (average >= 86 && average<= 100)
{
cout << " Your average is: " << average << endl; "Excellent ! Congratualtions ! "
; }
else if (average >= 85 && average <= 70)
{

cout << " Your average is: " << average << endl; " Fair ! "
;}
if (average <= 69)
{
cout << " Your average is: " << average << endl; " Poor ! "
;}

//finish up
cout << "Program will now terminate." << endl;

// I always create this char variable to pause my program till I want it to exit
cin >> wait;


;}
I tried it and it didn't work eather with me ,,I will write anew program and back to you ,
this is my work and it didn't work at first bcoz the name you declear it as int ,,not string so I remove it you can declear it as string and continuee


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
#include <iostream>
using namespace std;
void main(){
	int sum,score1,score2,score3,score4,score5;
	float average;
	
	cout<<"enter your score";
	cin>>score1>>score2>>score3>>score4>>score5;
	sum=score1+score2+score3+score4+score5;
	average=sum/5;
if (average >= 86 && average<= 100)
{
cout << " Your average is: " << average << endl<<"Excellent ! Congratualtions ! ";
}


else if (average >= 85 && average <= 70)
{

cout <<" Your average is: " << average << endl<<" Fair ! ";
}
else if (average <= 69)
{
cout <<" Your average is: " << average << endl<<" Poor ! ";
}
}
Topic archived. No new replies allowed.