Question: Our password requirements are exactly the same as in the homework problem. Minimum length of twelve characters At least one UPPER CASE letter ( A
Our password requirements are exactly the same as in the homework problem.
Minimum length of twelve characters
At least one UPPER CASE letter AZ
At least one lower case letter az
At least one digit
At least one "special" character printable but not alphanumeric
No space characters
Write a program that reads a list of candidate passwords the number of passwords in the list is unknown and states the number of passwords that meet our qualifications. There is no need to use an array in this program; just read the passwords one line at a time hint hint test them, and keep track of the count of valid and invalid passwords.
I have a code, but I don't think it is reading the file line by line and I think its including space characters. How do I get the code to read line by line and make sure there are no space characters?
#include
#include
#include
#include
using namespace std;
bool isValidPasswordconst string& password
if passwordlength
return false;
bool hasUpperCase false;
bool hasLowerCase false;
bool hasDigit false;
bool hasSpecialChar false;
bool hasNoSpace true
for char password
if isupperpassword
hasUpperCase true;
else if islowerpassword
hasLowerCase true;
else if isdigitpassword
hasDigit true;
else if isprintpassword && isalnumpassword
hasSpecialChar true;
return hasUpperCase && hasLowerCase && hasDigit && hasSpecialChar;
int main
ifstream inputFilePasswordstxt;
if inputFile.isopen
cout "Error opening file." endl;
return ;
int validCount ;
int invalidCount ;
string password;
while inputFile password
if isValidPasswordpassword
validCount;
else
invalidCount;
cout "Total number of valid passwords are validCount endl;
cout "Total number if invalid passwords are invalidCount endl;
inputFile.close;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
