Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code has for underlined in red and I am not sure why. What am I missing? / / Password Checker Quiz #include #include #include

My code has "for" underlined in red and I am not sure why. What am I missing?
//Password Checker Quiz
#include
#include
#include
#include
using namespace std;
bool isValidPassword(const string& password){
if (password.length()<12){
return false;
}
bool hasUpperCase = false;
bool hasLowerCase = false;
bool hasDigit = false;
bool hasSpecialChar = false;
bool hasNoSpace = false
for (char c : password){
if (isupper(c)){
hasUpperCase = true;
}
else if (islower(c)){
hasLowerCase = true;
}
else if (isdigit(c)){
hasDigit = true;
}
else if (isprint(c) && !isalnum(c)){
hasSpecialChar = true;
}
else if (isspace(c)){
hasNoSpace = true;
}
}
return hasUpperCase && hasLowerCase && hasDigit && hasSpecialChar && hasNoSpace;
}
int main(){
ifstream inputFile("Passwords.txt");
if (!inputFile.is_open()){
cout << "Error opening file." << endl;
return 1;
}
int validCount =0;
int invalidCount =0;
string password;
while (inputFile >> password){
if (isValidPassword(password)){
validCount++;
}
else {
invalidCount++;
}
}
cout << "Total number of valid passwords are "<< validCount << endl;
cout << "Total number if invalid passwords are "<< invalidCount << endl;
inputFile.close();
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

What are the purposes of promotion ?

Answered: 1 week ago

Question

How were the HR functions affected by Hurricane Rita?

Answered: 1 week ago

Question

What information might lead you to choose working for the company?

Answered: 1 week ago

Question

Which environment factor(s) did Hurricane Rita affect? Discuss.

Answered: 1 week ago