please use C programming Password Verifier You are developi
please use C++ programming
#Password Verifier -
You are developing a software package that requires users to enter their own passwords. Your software requires that user passwords meet the following criteria:
the password should be at least 6 characters long
the password should contain at least one uppercase and at at least one lowercase letter
the password should have at least one digit.
the password should contain one of the following characters: ! @ # $ % but no other special characters
Write a program that asks the user for a password and verifies that it meets the stated criteria. If it doesn\'t, the program should display a message telling the user why.
User interface is important!
You should post pseudocode
Your code should have appropriate comments
Your code should be well-formatted, with camel case variables
Variables should be self-descriptive
Your code should have functions (besides main!)
Your functions should only do one thing
HINT: you should be passing pointers to functions
Solution
C++ code:
#include <bits/stdc++.h>
using namespace std;
bool checklength( string s)
{
if(s.length() < 6)
{
return false;
}
else
{
return true;
}
}
bool checkuppercase( string s)
{
for (int i = 0; i < s.length(); ++i)
{
if(int(s[i]) >= 65 and int(s[i]) <= 90)
{
return true;
}
}
return false;
}
bool checklowercase( string s)
{
for (int i = 0; i < s.length(); ++i)
{
if(int(s[i]) >= 97 and int(s[i]) <= 122)
{
return true;
}
}
return false;
}
bool checkdigit(string s)
{
for (int i = 0; i < s.length(); ++i)
{
if(int(s[i]) >= 48 and int(s[i]) <= 57)
{
return true;
}
}
}
bool checkspecialchar( string s)
{
for (int i = 0; i < s.length(); ++i)
{
if(int(s[i]) == 33 or int(s[i]) == 64 or int(s[i]) == 35 or int(s[i]) == 36 or int(s[i]) == 37)
{
return true;
}
}
return false;
}
bool anyotherspecialchars(string s)
{
for (int i = 0; i < s.length(); ++i)
{
bool c1 = (int(s[i]) >= 65 and int(s[i]) <= 90);
bool c2 = (int(s[i]) >= 97 and int(s[i]) <= 122);
bool c3 = (int(s[i]) >= 48 and int(s[i]) <= 57);
bool c4 = (int(s[i]) == 33 or int(s[i]) == 64 or int(s[i]) == 35 or int(s[i]) == 36 or int(s[i]) == 37);
if(c1 or c2 or c3 or c4)
{
continue;
}
else
{
return false;
}
}
return true;
}
int main()
{
string s;
cout << \"Enter Password\ \";
cin >> s;
bool invalid = false;
if(checklength(s) == false)
{
cout << \"Invalid password, the password should be at least 6 characters long\ \";
invalid = true;
}
if(checkuppercase(s) == false)
{
cout << \"Invalid password, the password should contain at least one uppercase letter\ \";
invalid = true;
}
if(checklowercase(s) == false)
{
cout << \"Invalid password, the password should contain at least one lowercase letter\ \";
invalid = true;
}
if(checkdigit(s) == false)
{
cout << \"Invalid password, the password should contain at least one digit\ \";
invalid = true;
}
if((checkspecialchar(s) == false) or (anyotherspecialchars(s) == false))
{
cout << \"Invalid password, the password should contain one of the following characters: ! @ # $\" << char(37) <<\"but no other special characters\ \";
invalid = true;
}
if(invalid == false)
{
cout << \"Password is valid\ \";
}
return 0;
}


