# Thread: argh.... why is the percent field always 0.00?

1. ## argh.... why is the percent field always 0.00?

Code:
```#include <iostream.h>

int main()

{
int Awbrey1;
int Awbrey2;
int Awbrey3;

int Berlin1;
int Berlin2;
int Berlin3;

cout<<"Number of votes for Awbrey in New York: ";
cin>>Awbrey1;
cout<<"Number of votes for Berlin in New York: ";
cin>>Berlin1;
cout<<"Number of votes for Awbrey in New Jersey: ";
cin>>Awbrey2;
cout<<"Number of votes for Berlin in New Jersey: ";
cin>>Berlin2;
cout<<"Number of votes for Awbrey in Connecticut: ";
cin>>Awbrey3;
cout<<"Number of votes for Berlin in Connecticut: ";
cin>>Berlin3;

long awbreytotal=(Awbrey1+Awbrey2+Awbrey3);
long berlintotal=(Berlin1+Berlin2+Berlin3);
long total=(awbreytotal+berlintotal);
double awbreypercent=double(((Awbrey1+Awbrey2+Awbrey3)/total)*100);
double berlinpercent=double(((Berlin1+Berlin2+Berlin3)/total)*100);

cout<<endl;
const int ColWidth=15;
cout.setf(ios::fixed);
cout.precision(2);

cout.setf(ios::left);
cout.width(ColWidth); cout<<"Name";
cout.setf(ios::right);
cout.width(ColWidth); cout<<"Percent"<<endl;

cout.setf(ios::left);
cout.width(ColWidth); cout<<"Awbrey";
cout.setf(ios::right);
cout.width(ColWidth); cout<<awbreytotal;
cout.width(ColWidth); cout<<awbreypercent<<endl;

cout.setf(ios::left);
cout.width(ColWidth); cout<<"Berlin";
cout.setf(ios::right);
cout.width(ColWidth); cout<<berlintotal;
cout.width(ColWidth); cout<<berlinpercent<<endl;

cout.setf(ios::left);
cout.setf(ios::right);
cout.width(ColWidth); cout<<total<<endl;
return (0);
}```
see the topic :9

2. Change the lines that calculate the percent to

double awbreypercent=((((double)Awbrey1+Awbrey2+Awbrey3)/total)*100);
double berlinpercent=((((double)Berlin1+Berlin2+Berlin3)/total)*100);

otherwise you're just doing integer division (which will have already been evaluated by the time you cast to double).