Program I made check it out if you want...... comment.... whatever
Code:
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
int main()
{
string Header("Welcome Enter your password: \n");
string line(28, '*');
string PassWord;
string TheKey = "Sshakey6791";
string Name;
string RealName = "steve";
string Anwser;
int count = 0;
do {
cout << line << endl << Header << line << endl;
cout << ">";
cin >> PassWord;
cout << endl;
if ( PassWord == TheKey )
{
cout << "Processing Information.."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << ".\n";
cout << "Welcome back \n";
cout << " What is your name again?\n>";
cin >> Name;
cout << endl;
if ( Name != RealName ) {
cout << "Thinking..."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << ".\n";
Sleep(2000);
cout << "That's not right!\n";
Sleep(2000);
cout << "You hack this, didn't you?\n>";
cin >> Anwser;
cout << endl;
if ( Anwser == "yes" || Anwser == "Yes" ) {
Sleep(2000);
cout << "Thanks for telling me the truth.\n";
cout << "But you have to go.\n";
Sleep(2000);
exit(1);
cout << endl;
} else if ( Anwser == "no" || Anwser == "No" ) {
Sleep(2000);
cout << "Your a lier\n";
Sleep(2000);
cout << "The Programming is shutting down!!!\n";
Sleep(2000);
exit(1);
cout << endl;
} else {
cout << "Thinking..."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << ".\n";
Sleep(2000);
cout << "That is not even an anwser.\n";
cout << "GoodBye\n";
Sleep(2000);
exit(1);
cout << endl;
}
}
}
count++;
if ( count == 3 ) {
cout << "Error!!\n";
cout << "Your being kicked. goodbye!!!\n";
Sleep(2000);
exit(1);
}
} while ( PassWord != TheKey );
if ( Name == RealName ) {
cout << "Thinking..."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << "."; Sleep(900); cout << ".\n";
Sleep(2000);
cout << "Sorry.. can never be to cauful.\n";
Sleep(1000);
cout << "Would you like to leave? \n>";
cin >> Anwser;
cout << endl;
if ( Anwser == "yes" || Anwser == "Yes" ) {
cout << "Goodbye.";
Sleep(3000);
exit(1);
cout << endl;
} else if ( Anwser == "no" || Anwser == "No" ) {
cout << "This program is not complete\n";
cout << "Sorry but program is going to end anyway\n";
} else {
cout << "Error!!!\n";
}
}
system("pause");
return(0);
}
After getting the password wrong 3 times the program will exit
New Password protector..... Check it out
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
const string HEADER ( "\t\t\tThree chances to get password right\n\n" );
const string line ( 80, '*' );
const string KeyWord = "metal";
string ThePassWord = "Sshakey6791";
string DefaultPassWord = "music";
string PassWord;
string NameEnter;
const string Name = "Steve";
string Answer;
string Type_Answer;
int count = 0;
cout << line << endl;
cout << HEADER;
cout << line << endl;
while ( true ) {
cout << "Enter name: ";
cin >> NameEnter;
if ( NameEnter != Name ) {
cout << NameEnter << " is not a valid. Please try again. \n\n";
} else if ( NameEnter == Name ) {
break;
}
}
do {
cout << "Enter password: ";
cin >> PassWord;
if ( PassWord == ThePassWord ) {
cout << "\nWhat is your favorit type of music?\n>";
cin >> Type_Answer;
if ( Type_Answer == KeyWord ) {
cout << "Welcome back "<< Name << endl;
} else {
cout << "\nYour not " << Name << endl;
cout << "Then who are your?\n>";
cin >> Answer;
if ( Answer == Name ) {
cout << "Your a bad lier. " << Name << " doesn't like " << Type_Answer << endl;
cout << "You have to go. GoodBye.\n";
cin.get();
} else {
cout << "Ooo so your name is " << Answer << ". Well you have to go sorry.\n";
cin.get();
}
}
}
count++;
if ( count == 3 ) {
cout << "Password has been changed\n";
ThePassWord.swap (DefaultPassWord);
}
} while ( PassWord != ThePassWord );
return(0);
}