Everything is coming out except for the average, what am I doing wrong?

``````#include <iostream>

#include <string>

#include <iomanip>

using namespace std;

int main()

{

string ssnumber;
int exam1 = 0, exam2 = 0, exam3 = 0, final = 0,count = 0, sum = 0;
int average1 = 0, average2 = 0, average3 = 0;

while (count < 3)

{

cout <<"SS Number";

cin >>ssnumber;

cout <<"Exam 1";

cin >>exam1;

cout <<"Exam 2";

cin >>exam2;

cout <<"Exam 3";

cin >>exam3;

cout <<"Final";

cin >>final;

cout <<"Average";

cout<<"Class average is:";

cin >>classaverage;

averagegrade = (exam1 + exam2+ exam3 + final) / 4;  <---------  This part right here.   It's not coming out.

classaverage = (average1 + average2 + average3) / 3;

count++;

cout<<setw(6)<<ssnumber<<setw(19)<<exam1<<setw(6)<<exam2<<setw(6)
<<exam3<<setw(6)<<final<<setw(6)<<average1<<setw(6)<<average2<<setw(12)

}

return 0;

}
``````

Sorry, ignore the initializer "sum = 0;" I'm not using that. Any help would be very much appreciated it.

Probably has something to do with you having "double" for averagegrade and classaverage while having "int" values for what's going into it. Change them to Int and see if it prints, or change everything else to "double"...

What does "not coming out" mean? What gets shown for `averagegrade`?

``````averagegrade = (exam1 + exam2+ exam3 + final) / 4;
``````

All of `exam1`, `exam2`, `exam3`, `final`, and `4` are integer values... so the compiler does integer division. For floating point arithmetic, at least one of the operands needs to be a floating point value... try this:

``````averagegrade = (exam1 + exam2+ exam3 + final) / 4.0;
``````

Well, the average is not printing out. I will try that thank you very much

Thank you to both!

You are getting the value of the variable "classaverage" as input and then computing the same..
check it out and change the logic..

And, try using the dividend as float or double value..I mean, use 4.0 instead of 4

look at the code and see that is what you want to do