Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,468 members, 7,816,095 topics. Date: Friday, 03 May 2024 at 04:40 AM

My C++ Voting System Program Algorithm - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / My C++ Voting System Program Algorithm (6421 Views)

My C++ CGPA Calculator Program / Simple Algorithm Exercise / Votestats - New Online Platform That Simulates And Models Nigeria Voting System (2) (3) (4)

(1) (Reply) (Go Down)

My C++ Voting System Program Algorithm by bet9ja(m): 8:39am On Jun 21, 2017
Hello coder,
I decided to play around with a voting program that will request for Voter's ID. The idea behind the identification is based on the idea of the South Africa ID number system. SA ID number is 13 digit which is made of individual Date of birth, Month of Birth, Gender and some other security random number. You can also enter a random 13 digit number on this program and it will work fine, but just for testing.

Security measures after preregistration of the voters:

The program request for your ID number
Check for voters eligibility based on their age through the ID, and display their age and gender.
Ask for security pin which will be assign during preregistration to individual.
Validate the security pin
Display the candidate and ask voters to choose their choice.
record the vote.

Like i said, this is just a program i am playing with. ID to test with: 8210120603087 PINCODE: 50505

#include <iostream>
#include <sstream>
using namespace std;


void candidate(int& selector)
{
string name;
cout <<"========================================= " << endl;
cout <<"=======WELCOME TO E-VOTING SYSTEM ======= " << endl;
cout <<"========================================= " << endl;
cout << "Enter 1 (ANPP) to vote MR OLUMIDE AYENI FOR PRESIDENT " << endl;
cout << "Enter 2 (ANC) to vote MR ZUMA ZUME FOR PRESIDENT " << endl;
cout << "Enter 3 (EFF) to vote MR JULIUS MALEMA FOR PRESIDENT " << endl;
cout << "Enter 4 (DA) to vote MRS VICTRESS MBETHA FOR PRESIDENT " << endl;
cout << "Please select: " << endl;
cin >> selector;

switch(selector)
{
case 1:
cout << "YOU SELECTED 1 (ANPP) TO VOTE MR OLUMIDE" << endl;
cout << "Enter your full name to confirm your vote: " << endl;
cin >> name;
cout << endl;
cout <<"========================================= " << endl;
cout << "THANK YOU " << name <<" FOR VOTING ANPP" << endl;
break;
case 2:
cout << "YOU SELECTED 2 (ANC) TO VOTE MR ZUMA ZUME" << endl;
cout << "Enter your full name to confirm your vote: " << endl;
cin >> name;
cout << endl;
cout <<"========================================= " << endl;
cout << "THANK YOU " << name <<" FOR VOTING ANC" << endl;
break;
case 3:
cout << "YOU SELECTED 3 (EFF) TO VOTE MR JULIUS MALEMA" << endl;
cout << "Enter your full name to confirm your vote: " << endl;
cin >> name;
cout << endl;
cout <<"========================================= " << endl;
cout << "THANK YOU " << name <<" FOR VOTING EFF" << endl;
break;
case 4:
cout << "YOU SELECTED 4 (ANC) TO VOTE MR VICTRESS MBETHA" << endl;
cout << "Enter your full name to confirm your vote: " << endl;
cin >> name;
cout << endl;
cout <<"========================================= " << endl;
cout << "THANK YOU " << name <<" FOR VOTING DA" << endl;
break;
default :
cout << " WRONG SELECTION, Please Select between 1 - 4 " << endl;

}
}

// Validate pin
bool verify(string PIN)
{
if(PIN.length() != 5)
return false;
else
return true;
}

int main()
{

string check, year, idNumber, gender, name;
int age, select;


cout << "Enter an ID number: ";
cin >> idNumber;
year = idNumber.substr(0,2);
gender = idNumber.substr(6, 1);

if(year < "10" )
year = "20" + year;
else
year = "19" + year;
if(idNumber.substr(6,1) <= "4" )
gender = "F";
else
gender = "M";

// Convert string to int for mathematical operation
stringstream(year) >> age;
age = 2017 - static_cast<int>(age);

//Validate age for eligibility
if(age < 18){
cout << "Your age is: " << age << endl;
cout << "You are NOT eligible to vote" << endl;
}
else
{
cout << "You are eligible to vote, your age is " << age <<"," << " gender "<< gender << endl;
cout << "Enter five digit pin number: ";
cin >> check;
if(verify(check) == 1 && check == "50505" )
{
candidate(select);
}
else
cout << "Invalid PIN" << endl;
}
return 0;
}

1 Like

Re: My C++ Voting System Program Algorithm by frankg1(m): 9:19am On Jun 21, 2017
u didnt implement a database... to check if the voter has voted before

1 Like

Re: My C++ Voting System Program Algorithm by BizBayo: 10:23am On Jun 21, 2017
wow, you should try and see how you can make it work in a cryptocurrency, 'Proof Of Vote' hashing
Re: My C++ Voting System Program Algorithm by bet9ja(m): 1:48pm On Jun 21, 2017
frankg1:
u didn't implement a database... to check if the voter has voted before
I don't mind to go further, i was only playing around thinking what i could develop with my C++ knowledge. I would like to develop this same program with more functionalities on mobile App using ionic framework, i will also appreciate collaborators.
Re: My C++ Voting System Program Algorithm by Hibrahym: 10:03pm On Jun 21, 2017
1. #include <conio.h>: Obsolete and Strange, u need to get a Good C++ Book
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list will help.

2. Multiple

cout << ....
cout << ....


Can be made into single cout << ...; call

3. use "\n" instead of << endl;

4. bool verify(string PIN) -->
bool verify(string& PIN)
bool verify(string_view PIN) //

1 Like

Re: My C++ Voting System Program Algorithm by Hibrahym: 10:04pm On Jun 21, 2017
BizBayo:
wow, you should try and see how you can make it work in a cryptocurrency, 'Proof Of Vote' hashing
Everything na CC?
Re: My C++ Voting System Program Algorithm by silento(m): 11:16pm On Jun 21, 2017
for hashing use the infamous bit shift operators ^
Re: My C++ Voting System Program Algorithm by bet9ja(m): 11:45pm On Jun 21, 2017
Hibrahym:
1. #include <conio.h>: Obsolete and Strange, u need to get a Good C++ Book
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list will help.

2. Multiple

cout << ....
cout << ....


Can be made into single cout << ...; call

3. use "\n" instead of << endl;

4. bool verify(string PIN) -->
bool verify(string& PIN)
bool verify(string_view PIN) //

Ignore the header file declaration, that was my bad. Those codes were written within an hour and i never bothered to cross-check. I was only concern with the logical functionalities.
Re: My C++ Voting System Program Algorithm by BizBayo: 8:44am On Jun 22, 2017
Hibrahym:

Everything na CC?

Somr parts are written with c++, some python. But really, Nigerian programmers need to up their game. I posted that I need a programmer for finishing job on a cryptocurrency, no one responded. Does that mean you guys dont study source codes of these cryptos? They are on github for free use and modification. Its a shame no one responded to my post.
Re: My C++ Voting System Program Algorithm by yahucoder(m): 5:57pm On Jun 23, 2017
Have done project like this using C#. The main idea is to developed a voting system for computer science student. Have done the GUI, the software will collate the result and tell you the winner once its time. I even went as far as wanted to implement fingerprint scanner so that student don't need to enter there matrix number. The system will just scan your fingerprint, and blocks you if you had voted before, but the school politics then make me drop the project and I was 80% closer to completion.
Re: My C++ Voting System Program Algorithm by bet9ja(m): 1:39am On Jun 24, 2017
yahucoder:
Have done project like this using C#. The main idea is to developed a voting system for computer science student. Have done the GUI, the software will collate the result and tell you the winner once its time. I even went as far as wanted to implement fingerprint scanner so that student don't need to enter there matrix number. The system will just scan your fingerprint, and blocks you if you had voted before, but the school politics then make me drop the project and I was 80% closer to completion.

You could have finished it and have the project under your belt.
Re: My C++ Voting System Program Algorithm by Hibrahym: 5:02am On Jun 24, 2017
BizBayo:


Somr parts are written with c++, some python. But really, Nigerian programmers need to up their game. I posted that I need a programmer for finishing job on a cryptocurrency, no one responded. Does that mean you guys dont study source codes of these cryptos? They are on github for free use and modification. Its a shame no one responded to my post.

By CC, I meant [b]C[/b]rypro[b]C[/b]urrency.

(I actually saw your post about the Crypto, never took it serious though)
Your wahala too much, which you want make peson study sef:
- BTC, I don't like it much, too much hype, no privacy
- ETH: not so decentrilised
- XMR: great for those who like the word "privacy"
- ZCash
- Dash, NOT Dash Coin
- Litecoin

Take a pick.
Re: My C++ Voting System Program Algorithm by frankg1(m): 8:12pm On Sep 24, 2017
bet9ja:

I don't mind to go further, i was only playing around thinking what i could develop with my C++ knowledge. I would like to develop this same program with more functionalities on mobile App using ionic framework, i will also appreciate collaborators.

I dont code in c++. I code C# and python. If u need collaborators, i am up for it
Re: My C++ Voting System Program Algorithm by LittleBigDick(m): 5:45am On Dec 30, 2022
Op code is fokn out of date

(1) (Reply)

Pls I Need Registration Key For Visual Web Developer 2005 Express Edition / Article: Why A Career In Computer Programming Sucks / [Code Request] Code for PHP Login And Signup

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 37
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.