#include<iostream>
#include<conio.h>
#include<fstream>
using namespace std;
class Vote
{
private:
int num;
string name,clas;
int age;
int id;
string sign;
int count;
string cadinate_vote;
ofstream votefile;
public:
void Candinate_Detail()
{
votefile.open("vot.txt",ios::app);
char more='Y';
while(more=='y'||more=='Y')
{
//cout << "enter number of candinates: ";
//cin >> num;
//for(count=1;count<=num;count++)
///{
cout << "enter candinate name:";
cin >> name;
cout << "enter candinate class:";
cin >> clas;
cout << "enter candinate age:";
cin >> age;
cout << "enter candinate id:";
cin >> id;
cout << "enter of Sign candinate?(A,B).... ";
cin >> sign;
cout << endl<<"------------------------------------------------" << endl;
votefile << name << "\n" << clas << "\n" << age << "\n" << id << "\n" << sign << endl;
cout << "if you want to more record?(y/n)....";
cin >> more;
}
// }
votefile.close();
}
void count_vote()
{
char more='Y';
string names;
int count_vote;
int a=0;
string line;
votefile.open("vot.txt",ios::app);
while(more=='y'||more=='Y')
{
cout << "eneter your vote: ";
cin >> cadinate_vote;
getline(cin,cadinate_vote);
if(votefile.is_open())
{
if(cadinate_vote==sign)
{
a++;
votefile << name << " vote= " << a;
}
cout << " name of candinate "<< name << " and vote=" << a << endl;
}
cout << "if you want to give mnore vote?(y/n)....";
cin >> more;
}
}
};
void getdata()
{
Vote vte;
vte.Candinate_Detail();
}
void give_vote()
{
Vote vte;
vte.count_vote();
}
int main()
{
int choice;
cout << "enter your choice;" << endl;
cout <<"---------------------------------" << endl;
cout << "1 for write candinate name;" << endl << "2 for voting;" << endl;
cin >> choice;
/*Vote vte;
switch(choice){
case 1:
vte.Candinate_Detail();
break;
case 2:
vte.count_vote();
break;
}
*/
switch(choice){
case 1:
getdata();
break;
case 2:
give_vote();
break;
}
getch();
return 0;
}
#include<conio.h>
#include<fstream>
using namespace std;
class Vote
{
private:
int num;
string name,clas;
int age;
int id;
string sign;
int count;
string cadinate_vote;
ofstream votefile;
public:
void Candinate_Detail()
{
votefile.open("vot.txt",ios::app);
char more='Y';
while(more=='y'||more=='Y')
{
//cout << "enter number of candinates: ";
//cin >> num;
//for(count=1;count<=num;count++)
///{
cout << "enter candinate name:";
cin >> name;
cout << "enter candinate class:";
cin >> clas;
cout << "enter candinate age:";
cin >> age;
cout << "enter candinate id:";
cin >> id;
cout << "enter of Sign candinate?(A,B).... ";
cin >> sign;
cout << endl<<"------------------------------------------------" << endl;
votefile << name << "\n" << clas << "\n" << age << "\n" << id << "\n" << sign << endl;
cout << "if you want to more record?(y/n)....";
cin >> more;
}
// }
votefile.close();
}
void count_vote()
{
char more='Y';
string names;
int count_vote;
int a=0;
string line;
votefile.open("vot.txt",ios::app);
while(more=='y'||more=='Y')
{
cout << "eneter your vote: ";
cin >> cadinate_vote;
getline(cin,cadinate_vote);
if(votefile.is_open())
{
if(cadinate_vote==sign)
{
a++;
votefile << name << " vote= " << a;
}
cout << " name of candinate "<< name << " and vote=" << a << endl;
}
cout << "if you want to give mnore vote?(y/n)....";
cin >> more;
}
}
};
void getdata()
{
Vote vte;
vte.Candinate_Detail();
}
void give_vote()
{
Vote vte;
vte.count_vote();
}
int main()
{
int choice;
cout << "enter your choice;" << endl;
cout <<"---------------------------------" << endl;
cout << "1 for write candinate name;" << endl << "2 for voting;" << endl;
cin >> choice;
/*Vote vte;
switch(choice){
case 1:
vte.Candinate_Detail();
break;
case 2:
vte.count_vote();
break;
}
*/
switch(choice){
case 1:
getdata();
break;
case 2:
give_vote();
break;
}
getch();
return 0;
}