Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started