Please Help me Correct my c++ Code


#1

Here is my c++ code for electronic voting machine idk where I went wrong please help me out I will be really thankful to you guys :wink:

here is the code

include

include

using namespace std;
int const size=50;

class ballot
{
int vote[];
int candidate; //candidate you want to create for votingint vote[size];
int ballot[5];
static int spballot; //spoil ballotpublic :
void getdisplay(void);
int choice;
};
int ballot :: spballot;

void ballot :: getdisplay(void)
{
cout<<"\n\n\nEnter how many candidate you want to make:-";
cin>>candidate;

static int a,b,c,d,e;
a=0;
a=b=c=d=e;

cout<<"\nEnter 1-5 Integers\n";
for(int i=0;i<candidate;i++)
{
cin>>vote[i];
switch(vote[i])
{
case 1:ballot[a];
a++;
break;
case 2:ballot[b];
b++;
break;
case 3:ballot[c];
c++;
break;
case 4:ballot[d];
d++;
break;
case 5:ballot[e];
e++;
break;
default : ++spballot;
}
}

//for displayingint choice;
do
{
cout<<"\n\n\n\nChoices Available\n";
cout<<"\n1) Scored By Ballot A\n";
cout<<"2) Scored By Ballot B\n";
cout<<"3) Scored By Ballot C\n";
cout<<"4) Scored By Ballot D\n";
cout<<"5) Scored By Ballot E\n";
cout<<"6) Spoilt Ballot\n";
cout<<"7) EXIT\n";
cout<<"Enter Your Choice :- ";
cin>>choice;
switch(choice)
{
case 1: cout<<"Scored By Ballot A is "<<a;
break;
case 2: cout<<"Scored By Ballot B is "<<b;
break;
case 3: cout<<"Scored By Ballot C is "<<c;
break;
case 4: cout<<"Scored By Ballot D is "<<d;
break;
case 5: cout<<"Scored By Ballot E is "<<e;
break;
case 6: cout<<"Spoil Ballot were "<<spballot;
break;
}
}
void main()
{
clrscr();
ballot o1;
o1.getdisplay();
}


#2

You'll need to describe the problem before asking for its cause.
Also helps a lot if you describe your reasoning about the problem (what prevents you from fixing it?) so that others have a fighting chance to understand what information you're missing.
Also note that code is sensitive to even small details being changed, so you'll also need to take greater care to ensure that the code you posted is intact. You can verify whether it is by copying the code from your post and see if you can reproduce your issue without modifying it first. (otherwise you changed it while posting it and others would have to guess about how to undo that change which isn't what they should be putting their effort into)

In other words, since you want something from others, make it easy for them to give you that, remove all unnecessary effort on their part.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.