Answer to Question #197631 in C++ for Muhammad Ali

Question #197631

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


1
Expert's answer
2021-05-24T00:11:37-0400
#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;
	}
	
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog