Advertisement
Guest User

Untitled

a guest
Mar 13th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string username="123456";
  8. string password;
  9. int inputpassword;
  10.  
  11.  
  12. for(int isAttempt = 0; isAttempt <=3; isAttempt++)
  13. {
  14. cout<<"Username:"<<endl;
  15. cin>>username;
  16. cout<<"Password:"<<endl;
  17. cin>>password;
  18.  
  19. if(username != "123456" && password != "1234")
  20. {
  21. cout<<"Invalid credential, the program terminates after 3 failed attempts"<<end;
  22. }
  23.  
  24. if(username == "123456" && password == "1234")
  25.  
  26. {
  27. cout<<"Successful first login! Please change your password immediately."<<endl;
  28. cout<<"New password must be 4-digit and different from the temporary password."<<endl;
  29.  
  30. }
  31. while(inputpassword == password && inputpassword.lenght()==4)
  32.  
  33. {
  34.  
  35. cout<<"New password must be 4-digit and different from the temporary password."<<endl;
  36. cout<<"New password:"<<endl;
  37. cin>>inputpassword;
  38.  
  39. }
  40.  
  41. if(inputpassword != password && input.lenght()==4)
  42. {
  43. cout<<"You have changed your password successfully! Please re-login"<<endl;
  44.  
  45. }
  46. else
  47.  
  48. cout<<"access granted!"<<endl;
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
  58. return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement