mercredi 25 février 2015

C++ if/else statements not properly outputting

currently, I am having an issue with this if/else statement. this is the source here:



#include "stdafx.h"
#include "iostream>*
#include iomanip>* //had to remove the < for the #include libraries to show

using namespace std;

int main()
{
string firstname, secondname;
const int A_SCORE = 90;
const int B_SCORE = 80;
const int C_SCORE = 70;
const int D_SCORE = 60;

int testscore1;
int testscore2;
int testscore3;
int testscore4;
int testscore5;
int testscore6;
int testscore7;
int testscore8;
int testscore9;
int testscore10;

cout << "Enter your 10 scores and I will average\n"
<< "the total score, and assign letter grades" << endl;

cin >> testscore1;
cin.ignore();
cin >> testscore2;
cin.ignore();
cin >> testscore3;
cin.ignore();
cin >> testscore4;
cin.ignore();
cin >> testscore5;
cin.ignore();
cin >> testscore6;
cin.ignore();
cin >> testscore7;
cin.ignore();
cin >> testscore8;
cin.ignore();
cin >> testscore9;
cin.ignore();
cin >> testscore10;
cin.ignore();

int sum = testscore1 + testscore2 + testscore3 + testscore4 + testscore5 + testscore6 + testscore7 + testscore8 + testscore9 + testscore10;
int average = sum / 10;

if (average == 90);
{
cout << "your average is an A.";
}

else if (average == 80);
{
cout << "you have an average of a B.";
}

else if (average == 70);
{
cout << "you have an average of a C.";
}

else (average == 60);
{
cout << "your average is a D.":
}

system("pause");

return 0;
}


what the goal of this homework assignment is, is to input 10 numerical grades and have an average print out to screen with a letter grade based on average of the 10 grades. I no matter what I input, I always get 'your grade is an A. I have went over my notes ad well as looking to goodle/StackOverflow for what could be wrong. I also get compile errors too, which I cannot figure out. If someone could give me any ideas on what could be causing the issue, I would greatly appreciate it!


Aucun commentaire:

Enregistrer un commentaire