I have a problem printing the winners in my Voting Program. Please help me finish it.
#include <iostream>
using namespace std;
void DisplayOptions();
//void DisplayOptionsVice();
int InputVote();
int UpdatePoll();
void DisplayPoll();
//void DisplayPollVice();
int VoteArray[5];
//-----------------------------
void main()
{
int option;
int loop;
int ctr=0;
for(loop=0; loop<6; ++loop)
{
VoteArray[loop]=0;
}
do
{
DisplayOptions();
option=UpdatePoll();
DisplayPoll();
ctr++;
} while (ctr<10);
/*for(loop=0; loop<6; ++loop)
{
VoteArray[loop]=0;
}
do
{
DisplayOptionsVice();
option=UpdatePoll();
DisplayPollVice();
ctr1++;
} while (ctr<10);*/
}
//-----------------------------
void DisplayOptions()
{
cout<<"The Student Council Online Voting System"<<endl<<endl
<<"*List of students running as President*"<<endl<<endl
<<"Options are:"<<endl<<endl
<<"Press 1 for Chariza Lyn Lopez."<<endl
<<"Press 2 for Mark Limtian."<<endl
<<"Press 3 for Johnvic Pronaci."<<endl
<<"Press 4 for Michael Benjamin Rubio."<<endl
<<"Press 5 for Joseph Tan."<<endl<<endl;
}
//------------------------------
int InputVote()
{
int option;
cin>>option;
return option;
};
//------------------------------
int UpdatePoll()
{
int option;
option=InputVote();
if ((option>=0) && (option<6))
VoteArray[0]++;
else
cout<<endl<<"Illegal entry, please re-enter."<<endl<<endl;
switch (option)
{
case 1:
VoteArray[1]++;
break;
case 2:
VoteArray[2]++;
break;
case 3:
VoteArray[3]++;
break;
case 4:
VoteArray[4]++;
break;
case 5:
VoteArray[5]++;
break;
}
return option;
}
//-----------------------------
void DisplayPoll()
{
int loop=0;
cout<<endl<<endl
<<"Total votes cast: "<<VoteArray[0]<<endl<<endl;
cout<<"Chariza Lyn Barrameda: |";
for (loop=0; loop<VoteArray[1]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[1]<<endl;
cout<<"Mark Limtian: |";
for (loop=0; loop<VoteArray[2]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[2]<<endl;
cout<<"Johnvic Pronaci |";
for (loop=0; loop<VoteArray[3]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[3]<<endl;
cout<<"Michael Benjamin Rubio: |";
for (loop=0; loop<VoteArray[4]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[4]<<endl;
cout<<"Joseph Tan: |";
for (loop=0; loop<VoteArray[5]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[5]<<endl;
cout<<endl<<"--------------------------"<<endl;
if(VoteArray[1]>VoteArray[2]&&VoteArray[1]>VoteArray[3]&&VoteArray[1]>VoteArray[4]&&VoteArray[1]>VoteArray[5])
cout<<"The elected President is Ms. Charizza Lyn Lopez"<<endl<<endl<<endl<<endl;
if(VoteArray[2]>VoteArray[1]&&VoteArray[2]>VoteArray[3]&&VoteArray[2]>VoteArray[4]&&VoteArray[2]>VoteArray[5])
cout<<"The elected President is Mr. Mark Limtian"<<endl<<endl<<endl<<endl;
if(VoteArray[3]>VoteArray[1]&&VoteArray[3]>VoteArray[2]&&VoteArray[3]>VoteArray[4]&&VoteArray[3]>VoteArray[5])
cout<<"The elected President is Mr. Johnvic Pronaci"<<endl<<endl<<endl<<endl;
if(VoteArray[4]>VoteArray[1]&&VoteArray[4]>VoteArray[2]&&VoteArray[4]>VoteArray[3]&&VoteArray[4]>VoteArray[5])
cout<<"The elected President is Mr. Michael Benjamin Rubio"<<endl<<endl<<endl<<endl;
if(VoteArray[5]>VoteArray[1]&&VoteArray[5]>VoteArray[2]&&VoteArray[5]>VoteArray[3]&&VoteArray[5]>VoteArray[4])
cout<<"The elected President is Mr. Joseph Tan"<<endl<<endl<<endl
}
/*void DisplayOptionsVice()
{
cout<<"The Student Council Online Voting System"<<endl<<endl
<<"*List of students running as Vice President*"<<endl<<endl
<<"Options are:"<<endl<<endl
<<"Press 1 for Elmer Angeles."<<endl
<<"Press 2 for E.R. Noel Manaois."<<endl
<<"Press 3 for Joannabel Pronaci."<<endl
<<"Press 4 for Roselyn Joy Rono."<<endl
<<"Press 5 for Kevin Edward Vicencio."<<endl<<endl;
}
int UpdatePoll();
void DisplayPollVice()
{
int loop;
cout<<endl<<endl
<<"Total votes cast: "<<VoteArray[0]<<endl<<endl;
cout<<"Elmer Angeles: |";
for (loop=0; loop<VoteArray[1]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[1]<<endl;
cout<<"E.R. Noel Manaois: |";
for (loop=0; loop<VoteArray[2]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[2]<<endl;
cout<<"Joannabel Pronaci |";
for (loop=0; loop<VoteArray[3]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[3]<<endl;
cout<<"Roselyn Joy Rono: |";
for (loop=0; loop<VoteArray[4]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[4]<<endl;
cout<<"Kevin Edward Vicencio: |";
for (loop=0; loop<VoteArray[5]; ++loop)
cout<<"-";
cout<<"* "<<VoteArray[5]<<endl;
cout<<endl<<"--------------------------"<<endl;
if(VoteArray[1]>VoteArray[2]&&VoteArray[1]>VoteArray[3]&&VoteArray[1]>VoteArray[4]&&VoteArray[1]>VoteArray[5])
cout<<"The elected Vice President is Mr. Elmer Rhoel Angeles."<<endl<<endl<<endl<<endl;
if(VoteArray[2]>VoteArray[1]&&VoteArray[2]>VoteArray[3]&&VoteArray[2]>VoteArray[4]&&VoteArray[2]>VoteArray[5])
cout<<"The elected Vice President is Mr. E.R. Noel Manaois."<<endl<<endl<<endl<<endl;
if(VoteArray[3]>VoteArray[1]&&VoteArray[3]>VoteArray[2]&&VoteArray[3]>VoteArray[4]&&VoteArray[3]>VoteArray[5])
cout<<"The elected Vice President is Mr. Joannabel Pronaci."<<endl<<endl<<endl<<endl;
if(VoteArray[4]>VoteArray[1]&&VoteArray[4]>VoteArray[2]&&VoteArray[4]>VoteArray[3]&&VoteArray[4]>VoteArray[5])
cout<<"The elected Vice President is Ms. Roselyn Joy Rono."<<endl<<endl<<endl<<endl;
if(VoteArray[5]>VoteArray[1]&&VoteArray[5]>VoteArray[2]&&VoteArray[5]>VoteArray[3]&&VoteArray[5]>VoteArray[4])
cout<<"The elected Vice President is Mr. Kevin Edward Vicencio."<<endl<<endl<<endl<<endl;
}*/