| |
/* vote analysis program
03/08/05 */
#include <iostream.h>
#include <lvpstring.h>
int main()
{
cout<<"--vote analysis program--"<<endl<<endl;
String Candidate1,Candidate2;
cout<<"enter name of first candidate:";
getline(cin,Candidate1);
cout<<"enter name of second candidate:";
getline(cin,Candidate2);
long Votes1,Votes2;
cout<<"enter votes for "<<Candidate1<<":";
cin>>Votes1;
cout<<"enter votes for" <<Candidate2<<":";
cin>>Votes2;
cout<<endl;
long VotesTotal=Votes1+Votes2;
double Percent1=100*double(Votes1)/VotesTotal;
double Percent2=100*double(Votes2)/VotesTotal;
const ColWidth=10;
cout.setf(ios::fixed);
cout.precision(2);
cout.setf(ios::left);
cout.width(ColWidth);cout<<"Candidate";
cout.setf(ios::right);
cout.width(ColWidth);cout<<"Votes";
cout.width(ColWidth);cout<<"Percent"<<endl;
cout.setf(ios::left);
cout.width(ColWidth);cout<<"Candidate1";
cout.setf(ios::right);
cout.width(ColWidth);cout<<"Votes1";
cout.width(ColWidth);cout<<Percent1<<endl;
cout.setf(ios::left);
cout.width(ColWidth);cout<<"Candidate2";
cout.setf(ios::right);
cout.width(ColWidth);cout<<"Votes2";
cout.width(ColWidth);cout<<Percent2<<endl;
cout.width(ColWidth);cout<<"TOTAL: "<<endl;
cout.width(ColWidth);cout<<VotesTotal<<endl;
if(Votes1==Votes2)
cout<<"its was a Tie!"<<endl;
return(0);
}
|