Professional Documents
Culture Documents
Electronic Voting Machine: by Alexander Aronowitz
Electronic Voting Machine: by Alexander Aronowitz
EVM
VOTING
MACHINE
By Alexander Aronowitz
TABLE
OF
• vote CONTE 01
•
•
•
NTS
Nominations
total votes
See nominations
02
03
04
• Add nominations 05
• Undo vote 06
• Exit 07
EVM
Electronic voting machine
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin varius, eros nec efficitur euismod, lectus
turpis sollicitudin augue, non ultricies enim nunc sit amet augue. Quisque ante magna, varius et
vehicula congue, viverra eu nulla.
EVM
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;
struct Leaf {
string name;
string electionSymbol;
int votes;
Leaf* next;
};
void initializeDefaultNominations() {
addNomination("PTI", "Bat");
addNomination("PMLN", "Lion");
addNomination("PPP", "Arrow");
}
void displayNominations() {
Leaf* current = root;
while (current != nullptr) {
cout << current->name << " - Symbol: " << current->electionSymbol
<< " - Votes: " << current->votes << endl;
current = current->next;
}
}
void undoVote() {
if (!voteStack.empty()) {
auto lastVote = voteStack.top();
lastVote.first->votes -= lastVote.second;
voteStack.pop();
cout << "Last vote undone." << endl;
} else {
cout << "No votes to undo." << endl;
}
}
void clearScreen() {
#ifdef _WIN32
system("cls");
#else
system("clear");
#endif
}
int main() {
initializeDefaultNominations();
int choice;
string nominationName;
string electionSymbol;
do {
cout << "\nEVM Menu:\n";
cout << "1. Vote\n";
cout << "2. See Nominations\n";
cout << "3. Total Votes for Nominations\n";
cout << "4. Add Nomination\n";
cout << "5. Undo Vote\n";
cout << "0. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
cin.ignore();
switch (choice) {
case 1:
cout << "Enter the nomination name to vote: ";
cin >> nominationName;
vote(nominationName);
break;
case 2:
displayNominations();
break;
case 3:
displayNominations();
break;
case 4:
cout << "Enter the new nomination name: ";
cin >> nominationName;
cout << "Enter the election symbol: ";
cin >> electionSymbol;
addNomination(nominationName, electionSymbol);
break;
case 5:
undoVote();
break;
case 0:
cout << "Exiting EVM. Thank you for participating!" << endl;
break;
default:
cout << "Invalid choice. Please try again." << endl;
}
clearScreen();
return 0;
}