Imagine you are developing a software package that requires the user to enter th
ID: 3682765 • Letter: I
Question
Imagine you are developing a software package that requires the user to enter their own passwords. Your software requires that user's passwords meet the following criteria: The password should be at least 6 characters long The password should contain at least one uppercase and at least one lowercase letter The password should contain at least one digit Write a program that asks for a password and verifies it meets the stated criteria. If it doesn't tell the user why. Ensure you use well formed functions,
Explanation / Answer
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main()
{
string pass;
cout << "Enter password: ";
cin >> pass;
for(int i = 0; i < pass.length(); i++)
{
bool Lower = islower(pass[i]);
if(!Lower)
cout << "Invalid. No lower case letter.";
bool Upper = isupper(pass[i]);
if(!Upper)
cout << "Invalid. No upper case letter.";
bool Num = isdigit(pass[i]);
if(!Num)
cout << "Invalid. No digit.";
}
if(pass.length() < 6)
cout << "Invalid. Password is not long enough.";
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.