Respuesta :
Missing Details in Question
The password criteria are not stated. For this program, I'll assume the following
- Password must contain at least 1 capital letter
- Password must contain at least 1 small letter
- Password must contain at least 1 digit
- Password must be at least 8 characters
See Attachment for Source File "MyName-Hwrk10A.cpp"
Answer:
// Comment explains difficult lines
#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;
int main()
{
//Enter your name here
int k,l,m;
/*
Integer variables k,l and m are used to count the number of Â
capital letters small letters and digits in the input string (password)
*/
//Initialize them to 0
k=0;l=0;m=0;
int length;
string pass;
cout<<"Password: ";
cin>>pass;
//Calculate length of input string
length = pass.length();
//The following variable is declared to determine if the input string meets criteria
int det = 0;
for(int i = 0;i<pass.length();i++)
{
 if(isupper(pass[i])){ k++;}
 if(islower(pass[i])){ l++;}
 if(isdigit(pass[i])){ m++;}  Â
}
if(k==0)
{
cout<<"Password doesn't contain capital letters "<<endl;
det++;
}
if(l==0)
{
cout<<"Password doesn't contain small letters "<<endl;
det++;
}
if(m==0)
{
cout<<"Password doesn't contain digit "<<endl;
det++;
}
if(length<8)
{
cout<<"Length of password is less than 8 "<<endl;
det++;
}
if(det == 0)
{
 cout<<"Password meets requirements "<<endl;
} Â Â
 return 0;
}