I have a project to create a simple polling system but my program is not working properly.
The result the program is giving is not proper and dont know where the problem lies. can u guys help me out with this.
U can see the function i've created to calculate the result u can see that below(resultNA53 or resultNA54). i think there is some syntactic error aswell. so please kindly have a look at my code and tell me where is the mistake.
Thanks and Regards.
//////////////////////// My Code Here ////////////////////////////////////
#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
#include <conio.h>
#include <fstream>
using namespace std;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct candidate /////// Information About Canidates ///////////
{
string name;
};
///// Instance Variable for NA /////
candidate NA53[10];
candidate NA54[10];
struct voter //////// Information about Voters ////////
{
string name;
int ID;
bool vote;
};
///// Instance Variable for NA 54 /////
voter NA_53[20];
voter NA_54[20];
/////// Variables for Checking Voters ID for Voters///////
int nic53;
int nic54;
////////////////////////////////////////////////// Function Use In Programme //////////////////////////////////////////////////
void Menu(); ////Completed////
void Help(); ////Completed////
void candidate53(); ////Completed////
void candidate54(); ////Completed////
void voter53(); ////Completed////
void voter54(); ////Completed////
void presiding(); ////Completed////
void checking(); ////Completed////
void vote53(); ////Completed////
void vote54(); ////Completed////
void resultNA53(); ////Completed////
void resultNA54(); ////Completed////
void thankyou(); ////Completed////
//////////////////////////////////// Variables for Vote Received By Each Canidate ///////////////////////////////////
////??? NA 53 ???////
float can53_1=0;
float can53_2=0;
float can53_3=0;
float can53_4=0;
float can53_5=0;
float can53_6=0;
float can53_7=0;
float can53_8=0;
float can53_9=0;
float can53_10=0;
////??? NA 54 ???////
float can54_1=0;
float can54_2=0;
float can54_3=0;
float can54_4=0;
float can54_5=0;
float can54_6=0;
float can54_7=0;
float can54_8=0;
float can54_9=0;
float can54_10=0;
///////////////////////////////////// For Counter Repetition ///////////////////////////////////////////////////
// for candidate //
int can_counter53=4;
int can_counter54=4;
// for voters //
int vot_counter53=5;
int vot_counter54=5;
int totalv=vot_counter53;
int totalv1=vot_counter54;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////// Main ///////////////////////////////////////////////////////////////////////////
int main()
{
///////////////////////////// Candidates Of NA 53 /////////////////////////////////////////
NA53[0].name="Maryam Nawaz";
NA53[1].name="Aqdas Hassaan";
NA53[2].name="Atif Ali";
NA53[3].name="Muhammad Fawad";
///////////////////////////// Candidates Of NA 54 /////////////////////////////////////////
NA54[0].name="Syed Ammar Ali";
NA54[1].name="Mehwish Javaid";
NA54[2].name="Hajra Gujjar";
NA54[3].name="Aqdas Hassaan";
///////////////////////////// Voters Of NA 53 with IDs /////////////////////////////////////////
NA_53[0].name="Mati Ullah";
NA_53[1].name="Nawaz Ali";
NA_53[2].name="Zahra Naveed";
NA_53[3].name="Sanum Baloch";
NA_53[4].name="Azhar Ali";
NA_53[0].ID=200;
NA_53[1].ID=201;
NA_53[2].ID=202;
NA_53[3].ID=203;
NA_53[4].ID=204;
///////////////////////////// Voters Of NA 54 with IDs /////////////////////////////////////////
NA_54[0].name="Imran Khan";
NA_54[1].name="Nawaz Sharif";
NA_54[2].name="Mazhar Khok";
NA_54[3].name="Meer Malik";
NA_54[4].name="Mubashir Ijaz";
NA_54[0].ID=100;
NA_54[1].ID=101;
NA_54[2].ID=102;
NA_54[3].ID=103;
NA_54[4].ID=104;
system("cls");
system("color 5B");
cout<<"\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<" |||| WELCOME TO SA AND ||||\n";
cout<<" |||| AQ METERSHAART ||||\n";
cout<<" |||| FUNNY SOFTWARES ||||\n\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<"\nLoading Please Wait(Depend On Your System)";
for (int i=0;i<5;i++)
{
cout<<".";
cout.flush();
_sleep(500);
}
unsigned long int choice;
bool bad=false;
while(true)
{
system("cls");
system("color 5F");
Menu();
do
{
if(bad)
{
cin.clear();
cin.ignore(1000,'\n');
cout<<"wrong input Enter again"<<endl;
}
cin>>choice;
bad=cin.fail();
}while(bad || choice<0);
switch(choice)
{
case 1:
{
system("cls");
system("color 5E");
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Welcome To Logged In Menu"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
int password=14047;
int pass;
bool bad1=false;
cout<<"\n\nYOU HAVE TO ENTER PASSWORD TO LOGIN"<<endl<<endl;
do
{
cout<<"\nPassword ===";
-flushall();
cin>>pass;
bad1=cin.fail();
if(bad1 || pass<0)
{
for (int i=0;i<5;i++)
{
cout<<".";
cout.flush();
_sleep(800);
}
system("cls");
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t INVALID PASSWORD"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"ACSESS DENIEND ENTER AGAIN.....!!!!"<<endl;
cin>>pass;
}
cin.clear();
cin.ignore(1000,'\n');
}while(bad1 || pass<0);
for (int i=0;i<5;i++)
{
cout<<".";
cout.flush();
_sleep(500);
}
if(pass==password)
{
presiding();
}
break;
}
case 2:
{
checking();
system("pause");
system("cls");
main();
break;
}
case 3:
{
Help();
break;
}
case 4:
{
thankyou();
break;
}
}
}
return 0;
}
///////////////////////////////////////// End Of Main ///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////// Functions ////////////////////////////////////////////////////////////////////////
//////////////////////////////////// Start of Menu Function ///////////////////////////////////////////////
void Menu()
{
cout<<"\n\n\t **<^>**<^>**<^>**<^>**<^>**<^>**<^>**<^>**<^>**<^>**"<<endl;
cout<<"\t **<!>**<!>**<!>**<!>**<!>**<!>**<!>**<!>**<!>**<!>**"<<endl<<endl;
cout<<"\t\t!!!!!!! WELLCOME TO POLLING STATION !!!!!!!\n\n";
cout<<"\t **<!>**<!>**<!>**<!>**<!>**<!>**<!>**<!>**<!>**<!>**"<<endl;
cout<<"\t **<~>**<~>**<~>**<~>**<~>**<~>**<~>**<~>**<~>**<~>**"<<endl;
cout<<"\n\t\tPLEASE PRESS\n";
cout<<"\t\t\"1\" For Presiding Officer\n";
cout<<"\t\t\"2\" For Voters\n";
cout<<"\t\t\"3\" For Voters Help\n";
cout<<"\t\t\"4\" For Exit\n";
cout<<"\t\tEnter Your Choice Now: ";
}
//////////////////////////////////// End Of Menu Function ///////////////////////////////////////////////
//////////////////////////////////// Start Of Presiding Function ///////////////////////////////////////////////
void presiding()
{
system("cls");
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***\n"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t WELLCOME TO PRESIDING OFFICER'S MENU\n";
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***\n\n"<<endl<<endl;
int choice2;
bool bad2=false;
cout<<"\t\t\t1: To see the total NA Areas"<<endl;
cout<<"\t\t\t2: To see the record of NA 53"<<endl;
cout<<"\t\t\t3: To see the record of NA 54"<<endl;
cout<<"\t\t\t4: Back to the main menu"<<endl;
cout<<"\t\t\tEnter Your Choice :";
do
{
cin>>choice2;
bad2=cin.fail();
if(bad2 || choice2<0)
{
cout<<"Wrong Input Try Again!!!!"<<endl;
}
cin.clear();
cin.ignore(1000,'\n');
}
while (bad2 || choice2<0);
if (choice2==1)
{
cout<<"NA 53"<<endl;
cout<<"NA 54"<<endl;
system("pause");
presiding();
}
else if (choice2==2)
{
system("cls");
char ch;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t NA 53 Editing Menu\n\n";
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
do
{
system("cls");
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t NA 53 Editing Menu\n\n";
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
int ch1;
bool bad3=false;
cout<<"\t\t\tPlease Choose your option"<<endl<<endl;
cout<<"\t\t\t1: Press 1 to Add the candidates"<<endl;
cout<<"\t\t\t2: Press 2 to update the candidates"<<endl;
cout<<"\t\t\t3: Press 3 to delete any candidate"<<endl;
cout<<"\t\t\t4: Press 4 to view the candidates list "<<endl;
cout<<"\t\t\t5: Press 5 to Add the voters"<<endl;
cout<<"\t\t\t6: Press 6 to update the voters"<<endl;
cout<<"\t\t\t7: Press 7 to delete any voters"<<endl;
cout<<"\t\t\t8: Press 8 to view the voters list"<<endl;
cout<<"\t\t\t9: Press 9 to See the results"<<endl;
cout<<"\t\t 10: Press 10 to go back to the presiding officer's menu"<<endl;
cout<<"\t\t 11: Press 11 to go back to the main menu\n"<<endl;
cout<<"\t\t Please Enter Your Choice :";
do
{
cin>>ch1;
if(bad3 || ch1<0)
{
cout<<"Wrong Input Try Again!!!!"<<endl;
}
cin.clear();
cin.ignore(1000,'\n');
}while (bad3 || ch1<0);
switch(ch1)
{
case 1:
{
system("cls");
candidate53();
break;
}
case 2:
{
for(int i=0;i<can_counter53;i++)
{
cout<<i+1<<":"<<NA53[i].name<<endl;
}
int update;
cout<<"Enter No. of Candidate To Be Update"<<endl;
cin>>update;
if(update<can_counter53+1)
{
cout<<"Enter New Name of Candidate Now"<<endl;
cin>>NA53[update-1].name;
cout<<"Successfully updated and Stored"<<endl;
}
else
{
cout<<"We dont have "<<update<<" Candidate"<<endl;
}
break;
}
case 3:
{
for(int i=0;i<can_counter53;i++)
{
cout<<i+1<<":"<<NA53[i].name<<endl;
}
int erase;
cout<<"Enter No. of Candidate To Be Delete"<<endl;
cin>>erase;
if(erase<can_counter53+1)
{
cout<<"Enter New Name of Candidate Now"<<endl;
cin>>NA53[erase-1].name;
cout<<"Successfully Deleted And Stored"<<endl;
}
else
{
cout<<"We Dont Have "<<erase<<" Candidate"<<endl;
}
break;
}
case 4:
{
cout<<"***!***>>><<<***!***"<<endl;
cout<<"CANDIDATES OF NA-53"<<endl;
cout<<"***!***>>><<<***!***"<<endl;
if(can_counter53>=1)
{
for(int i=0;i<can_counter53;i++)
{
cout<<i+1<<":"<<NA53[i].name<<endl;
}
}
else
{
cout<<"No Candidate Is Added In This List"<<endl;
}
break;
}
case 5:
{
system("cls");
voter53();
break;
}
case 6:
{
for(int i=0;i<vot_counter53;i++)
{
cout<<i+1<<":"<<NA_53[i].name<<"\t\t"<<NA_53[i].ID<<endl;
}
int vupdate;
cout<<"Enter No. of Voter To Be Update"<<endl;
cin>>vupdate;
if(vupdate<vot_counter53+1)
{
cout<<"Enter New Name of Voter Now"<<endl;
cin>>NA_53[vupdate-1].name;
cout<<"Enter New ID of Voter Now"<<endl;
cin>>NA_53[vupdate-1].ID;
cout<<"Successfully Updated and Stored"<<endl;
}
else
{
cout<<"We Dont Have "<<vupdate<<"th Voter"<<endl;
}
break;
}
case 7:
{
for(int i=0;i<vot_counter53;i++)
{
cout<<i+1<<":"<<NA_53[i].name<<"\t\t"<<NA_53[i].ID<<endl;
}
int verase;
cout<<"Enter No. of Voter To Be Deleted"<<endl;
cin>>verase;
if(verase<vot_counter53+1)
{
cout<<"Delete Name of Voter Now"<<endl;
cin>>NA_53[verase-1].name;
cout<<"Delete ID of Voter Now"<<endl;
cin>>NA_53[verase-1].name;
cout<<"Successfully Updated and Stored"<<endl;
}
else
{
cout<<"We Dont Have "<<verase<<"th Voter"<<endl;
}
break;
}
case 8:
{
cout<<"NAMES VOTER ID"<<endl<<endl;
for(int i=0;i<vot_counter53;i++)
{
cout<<i+1<<":"<<NA_53[i].name<<"\t\t"<<NA_53[i].ID<<endl;
}
break;
}
case 9:
{
resultNA53();
break;
}
case 10:
{
presiding();
break;
}
case 11:
{
system("pause");
main();
break;
}
default:
{
cout<<"Wrong Input"<<endl;
break;
}
}
cout<<"\nDo You Want To Continue To NA 53 Editing Menu? (y/n)"<<endl;
cin>>ch;
cout<<endl;
}while(ch=='Y' || ch=='y');
}
else if (choice2==3)
{
system("cls");
char ch22;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t NA 54 Editing Menu\n\n";
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
do
{
system("cls");
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t NA 54 Editing Menu\n\n";
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
int ch2;
bool bad4=false;
cout<<"\t\t\tPlease Choose your option"<<endl<<endl;
cout<<"\t\t\t1: Press 1 to Add the candidates"<<endl;
cout<<"\t\t\t2: Press 2 to update the candidates"<<endl;
cout<<"\t\t\t3: Press 3 to delete any candidate"<<endl;
cout<<"\t\t\t4: Press 4 to view the candidates list "<<endl;
cout<<"\t\t\t5: Press 5 to Add the voters"<<endl;
cout<<"\t\t\t6: Press 6 to update the voters"<<endl;
cout<<"\t\t\t7: Press 7 to delete any voters"<<endl;
cout<<"\t\t\t8: Press 8 to view the voters list"<<endl;
cout<<"\t\t\t9: Press 9 to See the results"<<endl;
cout<<"\t\t 10: Press 10 to go back to the presiding officer's menu"<<endl;
cout<<"\t\t 11: Press 11 to go back to the main menu\n"<<endl;
cout<<"\t\t Please Enter Your Choice :";
do
{
cin>>ch2;
if(bad4 || ch2<0)
{
cout<<"Wrong Input!!!!"<<endl;
}
cin.clear();
cin.ignore(1000,'\n');
}while (bad4 || ch2<0);
switch(ch2)
{
case 1:
{
system("cls");
candidate54();
break;
}
case 2:
{
for(int i=0;i<can_counter54;i++)
{
cout<<i+1<<":"<<NA54[i].name<<endl;
}
int update;
cout<<"Enter No. of Candidate To Be Update"<<endl;
cin>>update;
if(update<can_counter54+1)
{
cout<<"Enter New Name of Candidate Now"<<endl;
cin>>NA54[update-1].name;
cout<<"Successfully Updated And Stored"<<endl;
}
else
{
cout<<"We Dont Have "<<update<<" Candidate"<<endl;
}
break;
}
case 3:
{
for(int i=0;i<can_counter54;i++)
{
cout<<i+1<<":"<<NA54[i].name<<endl;
}
int erase;
cout<<"Enter No. of Candidate To Be Delete"<<endl;
cin>>erase;
if(erase<can_counter54+1)
{
cout<<"Enter New Name of Candidate Now"<<endl;
cin>>NA54[erase-1].name;
cout<<"Successfully Deleted And Stored"<<endl;
}
else
{
cout<<"We Dont Have "<<erase<<" Candidate"<<endl;
}
break;
}
case 4:
{
cout<<"***!***<<<>>>***!***"<<endl;
cout<<"CANDIDATES OF NA-54"<<endl;
cout<<"***!***<<<>>>***!***"<<endl;
if(can_counter54>=1)
{
for(int i=0;i<can_counter54;i++)
{
cout<<i+1<<":"<<NA54[i].name<<endl;
}
}
else
{
cout<<"No Candidate Is Added In This List"<<endl;
}
break;
}
case 5:
{
system("cls");
voter54();
break;
}
case 6:
{
for(int i=0;i<vot_counter54;i++)
{
cout<<i+1<<":"<<NA_54[i].name<<" "<<NA_54[i].ID<<endl;
}
int vupdate;
cout<<"Enter No. of Voter To Be Update"<<endl;
cin>>vupdate;
if(vupdate<vot_counter54+1)
{
cout<<"Enter New Name of Voter Now"<<endl;
cin>>NA_54[vupdate-1].name;
cout<<"Enter New ID of Voter Now"<<endl;
cin>>NA_54[vupdate-1].ID;
cout<<"Successfully Updated and Stored"<<endl;
}
else
{
cout<<"we dont have "<<vupdate<<"th voter"<<endl;
}
break;
}
case 7:
{
for(int i=0;i<vot_counter54;i++)
{
cout<<i+1<<":"<<NA_54[i].name<<" "<<NA_54[i].ID<<endl;
}
int verase;
cout<<"Enter No of voter to be Deleted"<<endl;
cin>>verase;
if(verase<vot_counter54+1)
{
cout<<"Delete name of voter now"<<endl;
cin>>NA_54[verase-1].name;
cout<<"Delete ID of voter now"<<endl;
cin>>NA_54[verase-1].name;
cout<<"Successfully updated and stored"<<endl;
}
else
{
cout<<"we dont have "<<verase<<"th voter"<<endl;
}
break;
}
case 8:
{
cout<<"NAMES VOTER ID"<<endl<<endl;
for(int i=0;i<vot_counter54;i++)
{
cout<<i+1<<":"<<NA_54[i].name<<"\t\t"<<NA_54[i].ID<<endl;
}
break;
}
case 9:
{
resultNA54();
break;
}
case 10:
{
presiding();
break;
}
case 11:
{
system("pause");
break;
}
default:
{
cout<<"Wrong Input"<<endl;
break;
}
}
cout<<"\nDo You Want To Continue To NA 54 Editing Menu? (y/n)"<<endl;
cin>>ch22;
cout<<endl;
}while(ch22=='Y' || ch22=='y');
}
else if (choice2==4)
{
main();
}
}
//////////////////////////////////// End Of Presiding Function ////////////////////////////////////////////////////
//////////////////////////////////// Start of NA 53 Voting Function ///////////////////////////////////////////////
void vote53()
{
int vote;
cout<<"Press 1 for vote "<<NA53[0].name<<endl;
cout<<"press 2 for vote "<<NA53[1].name<<endl;
cout<<"Press 3 for vote "<<NA53[2].name<<endl;
cout<<"press 4 for vote "<<NA53[3].name<<endl;
if(can_counter53>4)
{
cout<<"Press 5 for vote "<<NA53[4].name<<endl;
}
if(can_counter53>5)
{
cout<<"Press 6 for vote "<<NA53[5].name<<endl;
}
if(can_counter53>6)
{
cout<<"Press 7 for vote "<<NA53[6].name<<endl;
}
if(can_counter53>7)
{
cout<<"Press 8 for vote "<<NA53[7].name<<endl;
}
if(can_counter53>8)
{
cout<<"Press 9 for vote "<<NA53[8].name<<endl;
}
if(can_counter53>9)
{
cout<<"Press 10 for vote "<<NA53[9].name<<endl;
}
cin>>vote;
switch(vote)
{
case 1:
{
can53_1++;
break;
}
case 2:
{
can53_2++;
break;
}
case 3:
{
can53_3++;
break;
}
case 4:
{
can53_4++;
break;
}
if(can_counter53>4)
{
case 5:
{
can53_5++;
break;
}
}
if(can_counter53>5)
{
case 6:
{
can53_6++;
break;
}
}
if(can_counter53>6)
{
case 7:
{
can53_7++;
break;
}
}
if(can_counter53>7)
{
case 8:
{
can53_8++;
break;
}
}
if(can_counter53>8)
{
case 9:
{
can53_9++;
break;
}
}
if(can_counter53>9)
{
case 10:
{
can53_10++;
break;
}
}
default:
{
cout<<"Wrong Input!!!!"<<endl;
}
}
}
//////////////////////////////////// End Of NA 53 Voting Function ///////////////////////////////////////////////
//////////////////////////////////// Start of NA 54 Voting Function ///////////////////////////////////////////////
void vote54(){
int vote1;
cout<<"Press 1 for vote "<<NA54[0].name<<endl;
cout<<"press 2 for vote "<<NA54[1].name<<endl;
cout<<"Press 3 for vote "<<NA54[2].name<<endl;
cout<<"press 4 for vote "<<NA54[3].name<<endl;
if(can_counter54>4)
{
cout<<"Press 5 for vote "<<NA54[4].name<<endl;
}
if(can_counter54>5)
{
cout<<"Press 6 for vote "<<NA53[5].name<<endl;
}
if(can_counter54>6)
{
cout<<"Press 7 for vote "<<NA53[6].name<<endl;
}
if(can_counter54>7)
{
cout<<"Press 8 for vote "<<NA53[7].name<<endl;
}
if(can_counter54>8)
{
cout<<"Press 9 for vote "<<NA53[8].name<<endl;
}
if(can_counter54>9)
{
cout<<"Press 10 for vote "<<NA53[9].name<<endl;
}
cin>>vote1;
switch(vote1)
{
case 1:
{
can54_1++;
break;
}
case 2:
{
can54_2++;
break;
}
case 3:
{
can54_3++;
break;
}
case 4:
{
can54_4++;
break;
}
if(can_counter54>4)
{
case 5:
{
can54_5++;
break;
}
}
if(can_counter54>5)
{
case 6:
{
can54_6++;
break;
}
}
if(can_counter54>6)
{
case 7:
{
can54_7++;
break;
}
}
if(can_counter54>7)
{
case 8:
{
can54_8++;
break;
}
}
if(can_counter54>8)
{
case 9:
{
can54_9++;
break;
}
}
if(can_counter54>9)
{
case 10:
{
can54_10++;
break;
}
}
default:
{
cout<<"Wrong Input!!!!"<<endl;
}
}
}
//////////////////////////////////// End Of NA 54 Voting Function ///////////////////////////////////////////////
/////////////////////////////////// Start Of Funtion To Add Candidates In NA 53 ///////////////////////////////////
void candidate53()
{
string name;
ofstream candidate53;
candidate53.open("candidate53.txt",ios::app);
char choice='y';
do
{
if(choice=='y')
{
system("cls");
}
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Welcome To Add Candidate in NA 53"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
if (can_counter53<10){
cout<<"\n\tYou Add "<<10-can_counter53<<" More Candidates\n";
cout<<"\tEnter candidate "<<can_counter53+1<<" Name ( Followed By '.' ) ";
getline(cin,NA53[can_counter53].name,'.');
name=NA53[can_counter53].name;
can_counter53++;
candidate53<<"Candidate Name is: "<<name<<endl;
candidate53<<"_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
}
else
{
cout<<"\nNot Added The Space Is Completed\n";
}
cout<<"\nDo You Want to Add Another Candidate.??"<<endl;
cout<<"Press 'Y' For Yes And 'N' For No :"<<endl;
cin>>choice;
}
while(tolower(choice)=='y');
candidate53.close();
}
/////////////////////////////////// End Of Funtion To Add Candidates In NA 53 ///////////////////////////////////
/////////////////////////////////// Start Of Funtion To Add Candidates In NA 54 ///////////////////////////////////
void candidate54()
{
string name;
ofstream candidate54;
candidate54.open("candidate54.txt",ios::app);
char choice='y';
do
{
if(choice=='y')
{
system("cls");
}
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Welcome To Add Candidate in NA 54"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
if (can_counter54<10){
cout<<"\n\tYou Add "<<10-can_counter54<<" More Candidates\n";
cout<<"\n\tEnter candidate "<<can_counter54+1<<" Name ( Followed By '.' ) ";
getline(cin,NA54[can_counter54].name,'.');
name=NA54[can_counter53].name;
can_counter54++;
candidate54<<"Candidate Name is: "<<name<<endl;
candidate54<<"_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
}
else
{
cout<<"\nNot Added The Space Is Completed\n";
}
cout<<"\nDo You Want to Add Another Candidate.??"<<endl;
cout<<"Press 'Y' For Yes And 'N' For No :"<<endl;
cin>>choice;
}
while(tolower(choice)=='y');
candidate54.close();
}
/////////////////////////////////// End Of Funtion To Add Candidates In NA 54 ///////////////////////////////////
/////////////////////////////////// Start Of Funtion To Add Voters In NA 53 ///////////////////////////////////
void voter53()
{
string name;
int id;
ofstream voter53;
voter53.open("voters53.txt",ios::app);
char choice='y';
do
{
if(choice=='y')
{
system("cls");
}
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Welcome To Add Voters in NA 53"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
if (vot_counter53<20){
cout<<"\n\n\tYou Add "<<20-vot_counter53<<" More Voters\n";
cout<<"Enter Name Of Voter "<<vot_counter53+1<<"( Followed By '.' ):"<<endl;
getline(cin,NA_53[vot_counter53].name,'.');
name=NA_53[vot_counter53].name;
cout<<"Enter ID of voter "<<vot_counter53+1<<" :"<<endl;
cin>>NA_53[vot_counter53].ID;
id=NA_53[vot_counter53].ID;
vot_counter53++;
voter53<<name<<endl;
voter53<<id<<endl;
voter53<<"_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
}
else
{
cout<<"\nNot Added Space Is Completed\n";
}
cout<<"\nDo You Want to Add Another Voter??????????"<<endl;
cout<<"Press 'Y' For Yes And 'N' For No :"<<endl;
cin>>choice;
}
while(tolower(choice)=='y');
voter53.close();
}
/////////////////////////////////// End Of Funtion To Add Voters In NA 53 ///////////////////////////////////
/////////////////////////////////// Start Of Funtion To Add Voters In NA 54 ///////////////////////////////////
void voter54()
{
string name;
int id;
ofstream voter54;
voter54.open("voters54.txt",ios::app);
char choice='y';
do
{
if(choice=='y')
{
system("cls");
}
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Welcome To Add Voters in NA 54"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
if (vot_counter54<20){
cout<<"\n\n\tYou Add "<<20-vot_counter54<<" More Voters\n";
cout<<"Enter Name Of Voter "<<vot_counter54+1<<"( Followed By '.' ):"<<endl;
getline(cin,NA_54[vot_counter54].name,'.');
name=NA_54[vot_counter54].name;
cout<<"Enter ID of voter "<<vot_counter54+1<<" :"<<endl;
cin>>NA_54[vot_counter54].ID;
id=NA_54[vot_counter54].ID;
vot_counter54++;
voter54<<name<<endl;
voter54<<id<<endl;
voter54<<"_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
}
else
{
cout<<"\nNot Added Space Is Completed\n";
}
cout<<"\nDo You Want to Add Another Candidate.??"<<endl;
cout<<"Press 'Y' For Yes And 'N' For No :"<<endl;
cin>>choice;
}
while(tolower(choice)=='y');
voter54.close();
}
/////////////////////////////////// End Of Funtion To Add Voter In NA 54 ///////////////////////////////////
/////////////////////////////////// Start Of Funtion Checking ///////////////////////////////////
void checking()
{
system("cls");
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***\n"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t WELLCOME TO Voters MENU\n";
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_\n"<<endl;
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***\n\n"<<endl<<endl;
int NA=0;
bool bad7=false;
cout<<"\t\t\tPlease Select your NA\n\n";
cout<<"\t\t\tPress 53: For NA53\n";
cout<<"\t\t\tPress 54: For NA54\n";
cout<<"\t\t\tPress 1: For Main Menu\n";
do
{
cin>>NA;
bad7=cin.fail();
if(bad7 || NA<0)
{
cout<<"\nWrong Input!!!"<<endl;
}
cin.clear();
cin.ignore(1000,'\n');
}while(bad7 || NA<0);
switch(NA)
{
case 53:
{
int n=0;
cout<<"Enter Your Voter(3 Digits) ID If You Are Registered\n";
cin>>nic53;
for(int i=0;i<vot_counter53;i++)
{
if(nic53==NA_53[i].ID)
{
if(NA_53[i].vote==0)
{
cout<<"yes\n";
NA_53[i].vote=1;
vote53();
}
else
{
cout<<"you have casted your vote"<<endl;
checking();
}
}
else
{
n++;
}
}
if(n>=5)
{
cout<<"Sorry u r not registered\n";
system("pause");
checking();
}
break;
}//end of case 53
case 54:
{
cout<<"Enter your voter(3 Digits) id if you are registered\n";
int m=0;
cin>>nic54;
cin.ignore();
for(int i=0;i<vot_counter54;i++)
{
if(nic54==NA_54[i].ID)
{
if(NA_54[i].vote==0)
{
cout<<"yes\n";
NA_54[i].vote=1;
vote54();
}
else
{
cout<<"You have casted your vote"<<endl;
checking();
}
}
else
{
m++;
}
}
if(m>=5)
{
cout<<"Sorry u r not registered\n";
checking();
}
break;
}//end of case 54
case 1:
{
main();
break;
}
}
}
/////////////////////////////////// End Of Funtion Checking ///////////////////////////////////
/////////////////////////////////// Starts Of Thank You Funtion ///////////////////////////////////
void thankyou()
{
system("cls");
system("color 5B");
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<" |||| THANK YOU For Using ||||\n";
cout<<" |||| SA & AQ METERSHAART ||||\n";
cout<<" |||| FUNNY SOFTWARES ||||\n\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<" ****!****<<<<<<<<<>>>>>>>>>****!****\n\n";
cout<<"\nTerminating The Programme\n";
for (int i=0;i<5;i++)
{
cout<<".";
cout.flush();
_sleep(1000);
}
exit(EXIT_SUCCESS);
}
/////////////////////////////////// End Of Thank You Funtion ///////////////////////////////////
/////////////////////////////////// Start Of NA 53 Result Funtion ///////////////////////////////////
void resultNA53()
{
float r1;
float r2;
float r3;
float r4;
float r5;
float r6;
float r7;
float r8;
float r9;
float r10;
int fmax=0;
r1=(can53_1/totalv)*100;
r2=(can53_2/totalv)*100;
r3=(can53_3/totalv)*100;
r4=(can53_4/totalv)*100;
r5=(can53_5/totalv)*100;
r6=(can53_6/totalv)*100;
r7=(can53_7/totalv)*100;
r8=(can53_8/totalv)*100;
r9=(can53_9/totalv)*100;
r10=(can53_10/totalv)*100;
system("cls");
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***"<<endl;
cout<<"\t\t\t RESULT'S OF NA - 53 \n";
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***"<<endl<<endl;
cout<<"NAMES OF CANDIDATES"<<" "<<"TOTAL VOTES"<<" "<<"PERCENTAGE\n"<<endl;
cout<<NA53[0].name<<" "<<can53_1<<" "<<r1<<endl;
cout<<NA53[1].name<<" "<<can53_2<<" "<<r2<<endl;
cout<<NA53[2].name<<" "<<can53_3<<" "<<r3<<endl;
cout<<NA53[3].name<<" "<<can53_4<<" "<<r4<<endl;
if(can_counter53>4)
{
cout<<NA53[4].name<<" "<<can53_5<<" "<<r5<<endl;
}
if(can_counter53>5)
{
cout<<NA53[5].name<<" "<<can53_6<<" "<<r6<<endl;
}
if(can_counter53>6)
{
cout<<NA53[6].name<<" "<<can53_7<<" "<<r7<<endl;
}
if(can_counter53>7)
{
cout<<NA53[7].name<<" "<<can53_8<<" "<<r8<<endl;
}
if(can_counter53>8)
{
cout<<NA53[8].name<<" "<<can53_9<<" "<<r9<<endl;
}
if(can_counter53>9)
{
cout<<NA53[9].name<<" "<<can53_10<<" "<<r10<<endl;
}
system("pause");
float Maxvote53[10];
Maxvote53[0]=r1;
Maxvote53[1]=r2;
Maxvote53[2]=r3;
Maxvote53[3]=r4;
Maxvote53[4]=r5;
Maxvote53[5]=r6;
Maxvote53[6]=r7;
Maxvote53[7]=r8;
Maxvote53[8]=r9;
Maxvote53[9]=r10;
int count=0;
for (int i=0;i<can_counter53;i++)
{
if (Maxvote53[i]>=fmax)
{
fmax=Maxvote53[i];
count++;
}
}
if (count==1)
{
for (int i=0;i<can_counter53;i++)
{
if (Maxvote53[i]==fmax)
{
cout<<"\n\n\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Winner! Winner! Congratulation"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\nCongratulation "<<NA53[i].name<<" You Win The Seat Of NA 53\n";
}
}
}
else if (count>=2)
{
cout<<"\n\n\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Tie! Tie! Best Of Luck Next Time"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
}
}
/////////////////////////////////// End Of NA 53 Result Funtion ////////////////////////////////////
/////////////////////////////////// Start Of NA 54 Result Funtion ///////////////////////////////////
void resultNA54()
{
float r1;
float r2;
float r3;
float r4;
float r5;
float r6;
float r7;
float r8;
float r9;
float r10;
int fmax=0;
r1=(can54_1/totalv)*100;
r2=(can54_2/totalv)*100;
r3=(can54_3/totalv)*100;
r4=(can54_4/totalv)*100;
r5=(can54_5/totalv)*100;
r6=(can54_6/totalv)*100;
r7=(can54_7/totalv)*100;
r8=(can54_8/totalv)*100;
r9=(can54_9/totalv)*100;
r10=(can54_10/totalv)*100;
system("cls");
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***"<<endl;
cout<<"\t\t\t RESULT'S OF NA - 54 \n";
cout<<"\t\t***<>***<>***<>***<>***<>***<>***<>***<>***<>***<>***"<<endl<<endl;
cout<<"NAMES OF CANDIDATES"<<" "<<"TOTAL VOTES"<<" "<<"PERCENTAGE\n"<<endl;
cout<<NA54[0].name<<" "<<can54_1<<" "<<r1<<endl;
cout<<NA54[1].name<<" "<<can54_2<<" "<<r2<<endl;
cout<<NA54[2].name<<" "<<can54_3<<" "<<r3<<endl;
cout<<NA54[3].name<<" "<<can54_4<<" "<<r4<<endl;
if(can_counter54>4)
{
cout<<NA54[4].name<<" "<<can54_5<<" "<<r5<<endl;
}
if(can_counter54>5)
{
cout<<NA54[5].name<<" "<<can54_6<<" "<<r6<<endl;
}
if(can_counter54>6)
{
cout<<NA54[6].name<<" "<<can54_7<<" "<<r7<<endl;
}
if(can_counter54>7)
{
cout<<NA54[7].name<<" "<<can54_8<<" "<<r8<<endl;
}
if(can_counter54>8)
{
cout<<NA54[8].name<<" "<<can54_9<<" "<<r9<<endl;
}
if(can_counter54>9)
{
cout<<NA54[9].name<<" "<<can54_10<<" "<<r10<<endl;
}
system("pause");
float Maxvote54[10];
Maxvote54[0]=r1;
Maxvote54[1]=r2;
Maxvote54[2]=r3;
Maxvote54[3]=r4;
Maxvote54[4]=r5;
Maxvote54[5]=r6;
Maxvote54[6]=r7;
Maxvote54[7]=r8;
Maxvote54[8]=r9;
Maxvote54[9]=r10;
int count=0;
for (int i=0;i<can_counter54;i++)
{
if (Maxvote54[i]>=fmax)
{
fmax=Maxvote54[i];
count++;
}
}
if (count==1)
{
for (int i=0;i<can_counter54;i++)
{
if (Maxvote54[i]==fmax)
{
cout<<"\n\n\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Winner! Winner! Congratulation"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\nCongratulation "<<NA54[i].name<<" You Win The Seat Of NA 54\n";
}
}
}
else if (count>=2)
{
cout<<"\n\n\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t Tie! Tie! Best Of Luck Next Time"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\t\t_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
}
}
/////////////////////////////////// End Of NA 54 Result Funtion ////////////////////////////////////
///////////////////////////////////// Start Of Help Function //////////////////////////////////////////////
void Help()
{
system("cls");
cout<<"\n\n-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_"<<endl;
cout<<"\n\n\t\t Assalam-o-Alaikum and Welcome\n\n";
cout<<"\tPress(2) to cast your vote when you press 2 you will\n";
cout<<"\tgo directly to the voters menu . Four options will be\n";
cout<<"\tavailable to you .If you want to see total Poll press\n";
cout<<"\tof NA press(1),if you want to cast a vote then press\n";
cout<<"\t(2) or (3) according to your pole .. Then system will\n";
cout<<"\tdemand your 3 digit ID, after entering your ID a list\n";
cout<<"\tof '' candidates '' will appear before you . Choose your\n";
cout<<"\tcandidate as per your wish and cast a vote.. If there\n";
cout<<"\tis any other query please visit our website ...........\n\n";
cout<<"\t ,--------------------------------------------------,\n";
cout<<"\t ||>>>>(www.SA&AQFunnyMetershaartSoftwares.com)<<<<||\n";
cout<<"\t '--------------------------------------------------'\n";
cout<<"\n\n_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-_-*-"<<endl;
system("pause");
}
///////////////////////////////////// End Of Help Function ///////////////////////////////////////////////
//////////////////////////////////////// End Of Functions /////////////////////////////////////////////