0% found this document useful (0 votes)
22 views5 pages

OOP Assignment Cat 2

This C++ program defines a ballot class to simulate voting. The class tracks the number of votes for each of 5 candidates (stored in variables a, b, c, d, e) and the number of spoiled ballots. The getdisplay() method gets user input for the number of candidates and each voter's selection, increments the corresponding candidate variable, and displays vote totals and the number of spoiled ballots upon user request.

Uploaded by

asya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views5 pages

OOP Assignment Cat 2

This C++ program defines a ballot class to simulate voting. The class tracks the number of votes for each of 5 candidates (stored in variables a, b, c, d, e) and the number of spoiled ballots. The getdisplay() method gets user input for the number of candidates and each voter's selection, increments the corresponding candidate variable, and displays vote totals and the number of spoiled ballots upon user request.

Uploaded by

asya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

NAME: ALYAN ASYA HAMED SALIM

CLASS: 3rd SEMESTER DBIT


UNIT: OOP
REG. NO: HDB112-COO5-0499/2015
EMAIL: [email protected]
CAT TWO
#include <iostream>

using namespace std;

int const size=50;

class ballot

int candidate;

int vote[size];

int choice; //candidate you want to create for voting int vote[size];

int ballot[5];

int spoiltballot;

int i;

public: //spoiltballot public :

void getdisplay(void);

};

void ballot:: getdisplay(void)

cout<<"enter how many candidate you want to make\n";

cin>>candidate;

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 : ++spoiltballot;

//for displayingint choice;

do
{

cout<<"\n\n\n\nChoices Available\n";

cout<<"\n1) Scored By Ballot A\n";

cout<<"\n2) Scored By Ballot B\n";

cout<<"\n3) Scored By Ballot C\n";

cout<<"\n4) Scored By Ballot D\n";

cout<<"\n5) Scored By Ballot E\n";

cout<<"\n6) Spoilt Ballot\n";

cout<<"\n7) 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<<"Spoiltballot were "<<spoiltballot;

break;

}
}

while(1);

int main()

ballot o1;

o1.getdisplay();

You might also like