Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote