election system c++ coding

June 6, 2011 at 22:36:59
Specs: Windows 7
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace::std;

#define N 5

char names[N][20];
int votes[N];
float percent[N];
int totalVotes;
int winnerPos;
int winnerVotes;

void get_input(){
int i;
totalVotes = 0;
for (i=0;i<N;i++)
cout << "Enter Last Name of Candidate" << endl;
cin >> names[i];
cout << "Enter Number of Votes received " << endl;
cin >> votes[i];
totalVotes += votes[i];


void calculate_winner()
int i;
winnerPos = 0;
winnerVotes = votes[0];

for (i=1;i<N;i++)
if ( winnerVotes < votes[i] )
winnerPos = i;
winnerVotes = votes[i];

void show_output(){
int i;
<<"Votes Rec"<<setiosflags(ios::left)<<setw(12)<<"% Of Total Votes"<<endl;
for ( i = 0; i < N; i++ )

cout<<"Winner of the election "<<names[winnerPos];

int main(){

return 0;

This is the code that i did. But in it, i have to create class Citizen and class voterslist. Under class citizen there should be name, age and etc and for each data member there should be two data function getter and setter. Class voterslist restrict the functionality of setage() function by override the setage() function of 'Citizen' class and the condition:

if age us greater that 18 the print "eligible for vote cast"

if less than 18

it prints "ages is less than 18" and sets the age value to default

....please someone help me with this...thanking in advance...really appreciate if u would help me..thank you.

See More: election system c++ coding

Report •

June 6, 2011 at 22:37:52
It's a voting system

Report •
Related Solutions

Ask Question