Hi i have an issue with this block of code even though all my braces have been opened and closed. Can someone please help out? Regards
expected unqualified-id before 'do'
expected '}' at end of input
expected unqualified-id at end of input
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;
class President
{
public:
//int ca=0,cb=0,cc=0,tv=0;
//string sa="Wamalwa",sb="Rotich",sc="Fatima";
int ca,cb,cc,tv;
string sa,sb,sc;
char pchoice,pchoice2;
void PWinner()
{
if (ca > cb && ca > cc)
{
cout<< "and the winner is : Wamalwa" << endl;
}
else if (cb > ca && cb > cc)
{
cout << "and the winner is : Rotich" << endl;
}
else if (cc > ca && cc > cb)
cout << "and the winner is : Fatima" << endl;
else
cout << "no winning president go for a runoff" << endl;
}
//my error is here
do
{
void PMenu()
{
cout<<"\t Presidential Elections\n\n";
cout<<"Candidates \n\n";
cout<<"<A>Wamalwa \n";
cout<<"<B>Rotich \n";
cout<<"<C>Fatima \n\n";
cout<<"Pick a candidate\n";
cin>>pchoice;
switch(pchoice)
{
case 'A':
case 'a':
ca++;
break;
case 'B':
case 'b':
cb++;
break;
case 'C':
case 'c':
cc++;
break;
}
while(pchoice2=='V' || pchoice2=='v');
}
if (pchoice2=='R' || pchoice2=='r')
{
cout<<"\t Chairman Elections\n\n";
cout<<"Candidates:"<<"\t results:"<<"\n\n";
cout<<"<A>Wamalwa : "<<ca<<"\n";
cout<<"<B>Rotich : "<<cb<<"\n";
cout<<"<C>Fatima : "<<cc<<"\n\n";
tv=ca+cb+cc;
cout<<"Total Votes : "<<tv<<"\n";
}
//private:
}
};
/*
class Senator
{
public:
//int pa=0,pb=0,pc=0,sv=0;
//string xa="Mona", xb="Nyachae", xc="Nzuki";
void SWinner()
{
//for senators
if (pa > pb && pa > pc)
{
cout<< "and the winner is : roto" << endl;
}
else if (pb > pa && pb > pc)
{
cout << "and the winner is : maish" << endl;
}
else if (pc > pa && pc > pb)
{
cout << "and the winner is : maish" << endl;
}
else
cout << "no winning senator go for a runoff" << endl;
}
void SMenu()
{
cout<<"\t senators Elections\n\n";
cout<<"Candidates \n\n";
cout<<"<D>Mona\n";
cout<<"<E>Nyachae\n";
cout<<"<F>Nzuki\n\n";
cout<<"Enter your vote : ";
cin>>choice;
//for senators
case 'D':
case 'd':
pa++;
break;
case 'E':
case 'e':
pb++;
break;
case 'F':
case 'f':
pc++;
break;
}
cout<<"-----------------------\n";
cout<<"Enter <v>vote <r> result and <q> quit : ";
cin>>schoice2;
// private:
};*/
int main()
{
//for senaors
//char Schoice, Sechoice;
President Wamalwa;
Wamalwa.PMenu();
Wamalwa.PWinner();
// do
//{
// }
//}
/*///////senators
cout<<"\t Secretary Elections\n\n";
cout<<"Candidates \n\n";
cout<<"<D>Mona"<<pa<<"\n";
cout<<"<E>Nyachae "<<pb<<"\n";
cout<<"<F>Nzuki "<<pc<<"\n";
cout<<"Enter your vote : ";*/
//sv=pa+pb+pc;
//}
system("pause");
return 0;
}