Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- #include <cstring>
- using namespace std;
- int main()
- {
- const int LENGTH = 101;
- char List[LENGTH];
- int Upper, Lower, Digit;
- // Password criteria promoted to user:
- cout << "Please create your password. The password should meet the following criteria:\n"
- << "The password should be at least ten characters long.\n"
- << "The password should contain at least two uppercase and at least one lowercase letter.\n"
- << "The password should have at least one digit.\n\n";
- do // Password is entered and is verifed.
- {
- Upper = Lower = Digit = 0;
- cout << "Please enter the password: "; // Initial password entry.
- cin.getline(List, LENGTH);
- for (int i = 0; i < strlen(List); i++)
- {
- if (isupper(List[i])) // Password is checked for proper uppercase, lowercase, and digits.
- Upper++;
- if (islower(List[i]))
- Lower++;
- if (isdigit(List[i]))
- Digit++;
- } // Password Verification process.
- if (strlen(List) < 10) // If proper instructions are not met, you are then prompted to enter the password again.
- cout << "Password is not at least ten characters long.\n";
- if (Upper == 0)
- cout << "Password does not have at least two uppercase letters.\n";
- if (Lower == 0)
- cout << "Password does not have at least one lowercase letter.\n";
- if (Digit == 0) "Password does not have at least one digit.\n";
- }
- while (Upper == 0 || Lower == 0 || Digit == 0 || strlen(List) < 10);
- 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.
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement