A very simple program that I wrote using C++ which allows the user to login in the system it gives the user three times to login successfully in the system. I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler in writing and testing this program. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
#include <iostream>
#include <string>
using namespace std;
int main()
{
string password = "admin";
string passwordEntry;
int attempts = 1;
cout << "THREE ATTEMPTS LOGIN SYSTEM";
cout <<"\n\n";
cout << "Enter your password: ";
getline(cin, passwordEntry, '\n');
while ( passwordEntry != password && attempts <=2 )
{
cout << "\n";
cout <<"Password Attempt No. : " <<attempts+1;
cout << "\n";
cout << "Enter Password Again : ";
getline(cin, passwordEntry, '\n');
attempts++;
}
if ( passwordEntry == password && attempts <=3 )
{
cout << "\n";
cout << "Access Granted in the System.";
}
else
{
cout << "\n";
cout << "Sorry, you are only allowed 3 password login attempts.";
cout << "\n\n";
}
}
No comments:
Post a Comment