Answer to Question #16563 in C++ for Antony Maina

Question #16563
Write a program that will be used for election 2012 in c++.
The program should have the returning officer logging in using a password and user name, he create clerks as other users who should log in using a password and user name, and also enter the candidates on offer names , age, gender, education.
The clerk is required to check the voters, national Id card, the voters card and enter the respective numbers in the system before the voter is allowed to continue with the voting process.
After the voting process the returning officer should tally the votes and run a report to announce the winner.
kindly assist the soonest..
1
Expert's answer
2012-10-16T11:42:03-0400
#include <iostream>
using namespace std;
#include <string>
#include <algorithm>
#include <vector>

int main (){
vector < pair<string, int> > candidat;
while (true)
{


cout<< "Are you a officer? - enter 1\n";
cout<< "Are you a voter? - enter 2\n";
cout<< "results - 0\n";





int mark; cin>> mark;
if (mark == 0) break;
if (mark == 1){
& cout<< "enter pass\n";
& string p, log;
& cin>> p;
& cout<<"enter log\n";
& cin>>log;
& if (p == "pass" && log == "login"){
&
& pair<string, int> c;
& while (true)
& {
& cout<<"Enter candidate name more\n if you don't want to contitue - enter e\n";
& cin>>c.first;
& c.second = 0;
& if (c.first == "e") break; else candidat.push_back(c);
& }
& }
}else {
& cout<< "You are voter! Congratulation!\n Make your choice\nEnter name of candidate below (from:\n";
& for (int i = 0 ; i < candidat.size() ; i++){
& cout<<candidat[i].first<<endl;
& }
& string name;
& cin>>name;
& for (int i = 0 ; i < candidat.size() ; i++){
& if (candidat[i].first == name) candidat[i].second++;
& }

}
}
cout<<"results: "<<endl;
for (int i = 0 ; i < candidat.size() ; i++){
& cout<< "Name "<<candidat[i].first << "& number of votes " << candidat[i].second <<endl;
}
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS