Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<string>
- using namespace std;
- int main()
- {
- string username="123456";
- string password;
- int inputpassword;
- for(int isAttempt = 0; isAttempt <=3; isAttempt++)
- {
- cout<<"Username:"<<endl;
- cin>>username;
- cout<<"Password:"<<endl;
- cin>>password;
- if(username != "123456" && password != "1234")
- {
- cout<<"Invalid credential, the program terminates after 3 failed attempts"<<end;
- }
- if(username == "123456" && password == "1234")
- {
- cout<<"Successful first login! Please change your password immediately."<<endl;
- cout<<"New password must be 4-digit and different from the temporary password."<<endl;
- }
- while(inputpassword == password && inputpassword.lenght()==4)
- {
- cout<<"New password must be 4-digit and different from the temporary password."<<endl;
- cout<<"New password:"<<endl;
- cin>>inputpassword;
- }
- if(inputpassword != password && input.lenght()==4)
- {
- cout<<"You have changed your password successfully! Please re-login"<<endl;
- }
- else
- cout<<"access granted!"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement