I am having a little trouble incorporating a simple password into a voting machine style program. If anybody can see what's wrong with it and point it out, I would be very grateful.
#include <iostream>
#include <iomanip>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
char choice;
string password = "jim";
string guess = "";
do
{
system("color F0");
system("CLS");
cout << "\n\n\n\n";
cout << setw(50) << "Voting Menu";
cout << endl << setw(40) << " George W. Bush" << ": 1 " ;
cout << endl << setw(40) << " John F. Kerry" << ": 2 ";
cout << endl << setw(40) << " EXIT" << ": 3 " << endl;
cout << endl << endl << setw(40) << "Please enter your choice :";
cin >> choice;
cin.get();
switch( choice)
{
case '1': system("CLS");
cout << "\n\n\n\n";
cout << setw(50) << "Thank you for voting. " << endl;
cin.get();
break;
case '2': system("CLS");
cout << "\n\n\n\n";
cout << setw(50) <<"Thank you for voting" << endl;
cin.get();
break;
case '3': system("CLS");
cout << "\n\n\n\n";
cout << setw(50) <<"Please enter supervisors password :" ;
cin >> guess;
if(guess == password)
{
cout << endl << endl << endl << setw(10) << ""
<< "Are you sure you want to quit and start counting votes? <Y/N> " << endl;
}
else
{
cin.get();
}
case '4': break;
}
}while( choice != '4');
return 0;
}
See after if(guess == password), it must revert back to the original screen if the password is incorrect. If the password is correct it will continue onto a Y/N option.
There's much more to do but I should be able to complete those parts on my own...hopefully.
BTW, is there a tutorial that explains simple Y/N parts?