#include
#include
#include
#include
#include
{
clrscr();
char name[6][100] = {"GOVERNER'S RULE","Mr.VIJAYAKANTH","Mr.KARUNANITHI","Ms.J.JAYA","Mr.SARATH","Mr.VIJAY"};
int i,j;
int v0=0,v1=0,v2=0,v3=0,v4=0,v5=0,v8=0;
char flag='y';
while(flag == 'y' || flag == 'Y')
{
clrscr();
cout<<"\n\tNAMES OF THE CANDITATES";
for(i=0;i<=5;i++)
{
cout<<"\n"<<<"."<
}
cout<<"\nIF VOTING IS OVER PRESS '6' TO SEE THE RESULT";
cout<<"\nENTER YOUR BEST CHOICE : ";
cin>>j;
switch(j)
{
case 0:
{
v0++;
break;
}
case 1:
{
v1++;
break;
}
case 2:
{
v2++;
break;
}
case 3:
{
v3++;
break;
}
case 4:
{
v4++;
break;
}
case 5:
{
v5++;
break;
}
case 6:
{
clrscr();
cout<<"\n~~~~~~~~~~~~~~~THE DETAILS OF THE ELECTION~~~~~~~~~~~~~~~~~\n";
cout<<"\n\t GOVERNER'S RULE : "<
cout<<"\n\t VIJAYAKANTH : "<
cout<<"\n\t J.JAYA : "<
cout<<"\n\t KARUNANITHI : "<
cout<<"\n\t SARATH : "<
cout<<"\n\t VIJAY : "<
cout<<"\n\t SPOILT VOTES : "<
if(v0>(v1 && v2 && v3 && v4 && v5))
{
cout<<"\n\t NOBODY WINS THE ELECTION!";
cout<<"\n\t THE RULE STRAIGHT A WAY GOES TO THE HANDS OF GOVERNOR";
}
else if(v1>v2 && v1>v3 && v1>v4 && v1>v5)
{
cout<<"\n\t VIJAYAKANTH WINS THE ELECTION!";
}
else if(v2>v1 && v2>v3 && v2>v4 && v2>v5)
{
cout<<"\n\t J.JAYA WINS THE ELECTION!";
}
else if(v3>v1 && v3>v2 && v3>v4 && v3>v5)
{
cout<<"\n\t KARUNANITHI WINS THE ELECTION!";
}
else if(v4>v1 && v4>v2 && v4>v3 && v4>v5)
{
cout<<"\n\t SARATH WINS THE ELECTION!";
}
else if(v5>v1 && v5>v2 && v5>v3 && v5>v4)
{
cout<<"\n\t VIJAY WINS THE ELECTION!";
}
else if(v1==0 && v2==0 && v3==0 && v4==0 && v5==0)
{
cout<<"\n\t NO VOTERS IDENTIFIED!";
}
else if((v1==v2) && (v1==v3) && (v3==v4) && (v4==v5))
{
cout<<"\n\t NO MAJORITY FOR ANY CANDIDATES!";
}
break;
}
default:
{
v8++;
}
}
cout<<"\nTO CONTINUE VOTING,PRESS (Y) OR (y) : ";
flag = getch();
}
return 0;
}
But once if close and open,we need to cast votes from the scratch.How do we overcome this problem
ReplyDelete