Advertisement
HighTechRedneck_

Untitled

Jul 15th, 2019
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <cctype>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.         const int LENGTH = 101;
  10.         char List[LENGTH];
  11.         int Upper, Lower, Digit;
  12.  
  13.                                 // Password criteria promoted to user:
  14.         cout << "Please create your password. The password should meet the following criteria:\n"
  15.                 << "The password should be at least ten characters long.\n"
  16.                 << "The password should contain at least two uppercase and at least one lowercase letter.\n"
  17.                 << "The password should have at least one digit.\n\n";
  18.  
  19.         do                      // Password is entered and is verifed.
  20.         {
  21.                 Upper = Lower = Digit = 0;
  22.  
  23.                 cout << "Please enter the password: ";                                          // Initial password entry.
  24.                 cin.getline(List, LENGTH);
  25.  
  26.                 for (int i = 0; i < strlen(List); i++)
  27.                 {
  28.  
  29.                          if (isupper(List[i]))                                                   // Password is checked for proper uppercase, lowercase, and digits.
  30.                             Upper++;
  31.                    
  32.                         if (islower(List[i]))
  33.                             Lower++;
  34.                    
  35.                         if (isdigit(List[i]))
  36.                             Digit++;    
  37.                 }           // Password Verification process.
  38.  
  39.                 if (strlen(List) < 10)                                                          // If proper instructions are not met, you are then prompted to enter the password again.
  40.                         cout << "Password is not at least ten characters long.\n";
  41.                 if (Upper == 0)
  42.                         cout << "Password does not have at least two uppercase letters.\n";
  43.                 if (Lower == 0)
  44.                         cout << "Password does not have at least one lowercase letter.\n";
  45.                 if (Digit == 0) "Password does not have at least one digit.\n";
  46.         }
  47.         while (Upper == 0 || Lower == 0 || Digit == 0 || strlen(List) < 10);
  48.  
  49.  
  50.         cout << "Password has now been verified. Your password is: " << List << endl;           // Once password is correctly entered the password is displayed for the user to see.
  51.  
  52.         return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement