Write a program that Ask to user input id and password If the Password and id is right than it has to show that you're successfully logged in!
if the passwords is wrong than it has to show the following message log in failed try again, also give 5 chances to log in and the password is still wrong than it has to show the message at 6 attempt that Your Attempts are expired try again after 60 seconds and program will be terminated
#include <iostream>
#include <string>
using namespace std;
int main()
{
const string USERNAME = "Admin";
const string PASSWORD = "password";
string username, password;
bool user_validated = false;
int i=0;
do
{
cout << "Insert ID:";
cin >> username;
cout << "Insert ID password:";
cin >> password;
if (username == USERNAME && password == PASSWORD)
{
cout << "you're successfully logged in!" << endl;
user_validated = true;
}
else
{
cout << " log in failed try again" << endl;
}
i=i+1;
} while (user_validated ==false && i<6 );
if(i==6){
cout << " Your Attempts are expired try again after 60 seconds" << endl;
}
}
Comments
Leave a comment