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;
//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;