#include <iostream.h>
#include <iomanip.h> // for setw() and setprecision()
#include <math.h> // for sqrt()
#include <fstream.h>
int main()
{

int j; // declare an integer called j
int i; // declare an integer called i

float vote1; //declare a floating point to display the gathered votes for candidate1 from SOUTH
float vote2; //declare a floating point to display the gathered votes for candidate1 from NORTH
float vote3; //declare a floating point to display the gathered votes for candidate1 from EAST
float vote4; //declare a floating point to display the gathered votes for candidate1 from WEST
float vote5; //declare a floating point to appoint the sum of votes for candidate1
float vote6; //declare a floating point to appoint the persentage of votes
float vote7; //declare a floating point to display the gathered votes for candidate2 from SOUTH
float vote8; //declare a floating point to display the gathered votes for candidate2 from NORTH
float vote9; //declare a floating point to display the gathered votes for candidate2 from EAST
float vote10; //declare a floating point to display the gathered votes for candidate2 from WEST
float vote11; //declare a floating point to appoint the sum of votes for candidate2
float vote12; //declare a floating point called test12.appoint the appoint the persentage of votes
float vote13; //declare a floating point to display the gathered votes for candidate3 from SOUTH
float vote14; //declare a floating point to display the gathered votes for candidate3 from NORTH
float vote15; //declare a floating point to display the gathered votes for candidate3 from EAST
float vote16; //declare a floating point to display the gathered votes for candidate3 from WEST
float vote17; //declare a floating point to appoint the sum of votes for candidate3
float vote18; //declare a floating point to appoint the persentage of votes
float vote19; //declare a floating point to display the gathered votes for candidate4 from SOUTH
float vote20; //declare a floating point to display the gathered votes for candidate4 from NORTH
float vote21; //declare a floating point to display the gathered votes for candidate4 from EAST
float vote22; //declare a floating point to display the gathered votes for candidate4 from WEST
float vote23; //declare a floating point to appoint the sum of votes for candidate1
float vote24; //declare a floating point to appoint the persentage of votes
cout<<"**********************************************************************************";
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"Enter the names of the four running candidates";
cout<<endl;
cout<<endl;
cout<<endl;
cout<<"First candidate name:";
char candidate1[20]; //declaration of an array statement
i=0;
j=0;
cin.get(candidate1[i]);
while(candidate1[i]!='\n')
{
i++;
cin.get(candidate1[i]);
}
cout<<endl;
cout<<"Mr ";

for(j=0; j<i; j++)
{
cout<<candidate1[j]; //output of first name
}


cout<<endl;
cout<<endl;
cout<<"Second candidate name:";
char candidate2[20]; //declaration of an array statement
i=0;
j=0;
cin.get(candidate2[i]);
while(candidate2[i]!='\n')
{
i++;
cin.get(candidate2[i]);
}
cout<<endl;
cout<<"Mr ";

for(j=0; j<i; j++)
{
cout<<candidate2[j]; //output of second name
}


cout<<endl;

cout<<endl;
cout<<"Third candidate name:";
char candidate3[20]; //declaration of an array statement
i=0;
j=0;
cin.get(candidate3[i]);
while(candidate3[i]!='\n')
{
i++;
cin.get(candidate3[i]);
}
cout<<endl;
cout<<"Mr ";

for(j=0; j<i; j++)
{
cout<<candidate3[j]; //output of third name
}


cout<<endl;
cout<<endl;
cout<<"Final candidate name:";
char candidate4[20]; //declaration of an array statement
i=0;
j=0;
cin.get(candidate4[i]);
while(candidate4[i]!='\n')
{
i++;
cin.get(candidate4[i]);
}
cout<<endl;
cout<<"Mr ";

for(j=0; j<i; j++)
{
cout<<candidate4[j]; //output of fourth name
}


cout<<endl;
cout<<endl;
cout<<"There are four(4) runner aps to this years' elections:";
cout<<endl;
for(j=0; j<i; j++)
{
cout<<candidate1[j];
};
cout<<endl;
for(j=0; j<i; j++)
{
cout<<candidate2[j];
};
cout<<endl;
for(j=0; j<i; j++)
{
cout<<candidate3[j];
};
cout<<endl;
for(j=0; j<i; j++)
{
cout<<candidate4[j];
};
cout<<endl;
cout<<"From four regions:NORTH,SOUTH,EAST and WEST.Please enter your vote for each candidate,from each region.";
cout<<endl;
cout<<"The program according to the votes taken will display the winner of this years' election.";
cout<<endl;
cout<<endl;
cout<<"The election program starts";
cout<<endl;
cout<<endl;
cout<<"Enter votes gathered for:";
for(j=0; j<i; j++)
{
cout<<candidate1[j];
};

cout<<endl;
cout<<endl;
cout<<"FROM THE NORTH:";
cin>>vote1; //input of gathered votes.saving in test1
while (vote1<0)// declare and confine where the user can't add negative vote
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote"; //warning:wrong number
cout<<endl;
cout<<"FROM THE NORTH:";
cin>>vote1;//input of gathered votes.saving in vote1

}
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>>vote2;//input of gathered votes.saving in vote2
while (vote2<0)
{
cout<<"ATTENTION!:No negative number,please reenter your vote"; //warning:wrong number
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote2;//input of gathered votes.saving in vote2
}
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote3;//input of gathered votes.saving in vote3
while ( vote3<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote"; //warning:wrong number
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote3;// input of gathered votes.saving in vote3
}
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote4; //input of gathered votes.saving in vote4
while ( vote4<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote4; //input of gathered votes.saving in vote4
}
vote5= vote1+ vote2+ vote3+ vote4;
cout<<endl;
cout<<"Enter votes gathered for:";
for(j=0; j<i; j++)
{
cout<<candidate2[j];
};
cout<<endl;
cout<<endl;
cout<<"FROM THE NORTH:";
cin>> vote7;//input of gathered votes.saving in vote7
while ( vote7<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE NORTH:";
cin>> vote7;//input of gathered votes.saving in vote7
}
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote8; //input of gathered votes.saving in vote8
while ( vote8<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote8;//input of gathered votes.saving in vote8
}
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote9; //input of gathered votes.saving in vote9
while ( vote9<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote9; //input of gathered votes.saving in vote9
}
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote10; //input of gathered votes.saving in vote10
while ( vote10<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote10; //input of gathered votes.saving in vote10
}
vote11= vote7+ vote8+ vote9+ vote10;
cout<<endl;
cout<<"Enter votes gathered for:";
for(j=0; j<i; j++)
{
cout<<candidate3[j];
};
cout<<endl;
cout<<endl;
cout<<"FROM THE NORTH:";
cin>> vote13; //input of gathered votes.saving in vote13
while ( vote13<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE NORTH:";
cin>> vote13; //input of gathered votes.saving in vote13
}
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote14; //input of gathered votes.saving in vote14
while ( vote14<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote14; //input of gathered votes.saving in vote14
}
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote15; //input of gathered votes.saving in vote15
while ( vote15<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote15; //input of gathered votes.saving in vote15
}
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote16; //input of gathered votes.saving in vote16
while ( vote16<0)
{
cout<<"ATTENTION!:No negative numbers,please reenter your vote";
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote16; //input of gathered votes.saving in vote16
}
vote17= vote13+ vote14+ vote15+ vote16;
cout<<endl;
cout<<"Enter votes gathered for:";
for(j=0; j<i; j++)
{
cout<<candidate4[j];
};
cout<<endl;
cout<<endl;
cout<<"FROM THE NORTH:";
cin>> vote19; //input of gathered votes.saving in vote19
while ( vote19<0)
{
cout<<"ATTENTION!:No negative numbers, please reenter your vote";
cout<<endl;
cout<<"FROM THE NORTH:";
cin>> vote19; //input of gathered votes.saving in vote19
}
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote20; //input of gathered votes.saving in vote20
while ( vote20<0)
{
cout<<"ATTENTION!:Nonegative numbers, please reenter your vote";
cout<<endl;
cout<<"FROM THE SOUTH:";
cin>> vote20; //input of gathered votes.saving in vote20
}
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote21; //input of gathered votes.saving in vote21
while ( vote21<0)
{
cout<<"ATTENTION!:No negative numbers, please reenter your vote";
cout<<endl;
cout<<"FROM THE EAST:";
cin>> vote21; //input of gathered votes.saving in vote21
}
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote22; //input of gathered votes.saving in vote22
while ( vote22<0)
{
cout<<"ATTENTION!:No negative numbers, please reenter your vote";
cout<<endl;
cout<<"FROM THE WEST:";
cin>> vote22; //input of gathered votes.saving in vote22
}
//calculation of votes gathered
vote23=vote19+vote20+vote21+vote22;
vote6=vote5/( vote5+ vote11+vote17+vote23)*100;
vote12=vote11/( vote5+vote11+vote17+vote23)*100;
vote18=vote17/( vote5+vote11+vote17+vote23)*100;
vote24=vote23/( vote5+vote11+vote17+vote23)*100;

cout<<endl;
cout<<endl;
cout <<"CANDIDATE"<<setw(8)<<"SOUTH"<<setw(9)<<"NORTH"<<setw(10)<<"EAST"<<setw(10)<<"WEST"<<setw(10)<<"TOTAL"<<setw(10)<<"%VOTE";//project a board
cout <<endl;
cout <<endl;
for(j=0; j<i; j++)
{
cout<<candidate1[j];
};
cout<<setw(10)<<vote1<<setw(10)<<vote2<<setw(10)<<vote3<<setw(10)<<vote4<<setw(10)<<vote5<<setw(10)<<vote6;
cout<<"%";
cout <<endl;
for(j=0; j<i; j++)
{
cout<<candidate2[j];
};
cout<<setw(10)<<vote7<<setw(10)<<vote8<<setw(10)<<vote9<<setw(10)<<vote10<<setw(10)<<vote11<<setw(10)<<vote12;
cout<<"%";
cout <<endl;
for(j=0; j<i; j++)
{
cout<<candidate3[j];
};
cout<<setw(10)<<vote13<<setw(10)<<vote14<<setw(10)<<vote15<<setw(10)<<vote16<<setw(10)<<vote17<<setw(10)<<vote18;
cout<<"%";
cout <<endl;
for(j=0; j<i; j++)
{
cout<<candidate4[j];
};
cout<<setw(9)<<vote19<<setw(10)<<vote20<<setw(10)<<vote21<<setw(10)<<vote22<<setw(10)<<vote23<<setw(10)<<vote24;
cout<<"%";
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
cout<<endl;
if(vote5>vote11)//if statement.appoint the winner of the election according to the votes
if(vote5>vote17)
if(vote5>vote23)
{ cout<<" According to the results from the votes gathered the winner of the 2003 elections is:";
for(j=0; j<i; j++)
{
cout<<candidate1[j]; //output of winner.candidate1
}
}

if(vote11>vote5)
if(vote11>vote17)
if(vote11>vote23)
{ cout<<" According to the results from the votes gathered the winner of the 2003 elections is:";
for(j=0; j<i; j++)
{
cout<<candidate2[j]; //output of winner.candidate2
}
}

if(vote17>vote11)
if(vote17>vote5)
if(vote17>vote23)
{ cout<<" According to the results from the votes gathered the winner of the 2003 elections is:";
for(j=0; j<i; j++)
{
cout<<candidate3[j]; //output of winner.candidate3
}
}

if(vote23>vote5)
if(vote23>vote11)
if(vote23>vote17)
{ cout<<" According to the results from the votes gathered the winner of the 2003 elections is:";
for(j=0; j<i; j++)
{
cout<<candidate4[j]; //output of winner.candidate4
}
}
cout<<endl;
cout<<endl;
cout<<endl;

cout<<"******************************************************************************";
cout<<endl;
return 0; //indicates successful termination
} //end main