Question

In: Computer Science

Please make it simply and easy for a beginner to follow -Write in C++ -Use Char...

Please make it simply and easy for a beginner to follow

-Write in C++

-Use Char library functions

Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties:

1. At least 8 characters long

2. Has at least one upper case letter

3. Has at least one lower case letter

4. Has at least one digit

5. Has at least on special characte

Solutions

Expert Solution

- In case any problem please comment, I am happy to assist you.

Program :-

#include <bits/stdc++.h>

using namespace std;

void CheckPassword(string& password)

{

int n = password.length(), flag=0;

bool hasLower = false, hasUpper = false, hasDigit = false;


for (int i = 0; i < n; i++) {

if (islower(password[i]))

hasLower = true;

if (isupper(password[i]))

hasUpper = true;

if (isdigit(password[i]))

hasDigit = true;

}

for(int i=0;i<n;i++)
{
if ((password[i]>=48 && password[i]<=57)||
(password[i]>=65 && password[i]<=90)||
(password[i]>=97 && password[i]<=122))
{
continue;
}
else
{
cout<<"String contains special character.\n";
flag=1;
break;
}
}

if(( hasLower && hasUpper && hasDigit && (n>=8)) && (flag==1) )
cout<< "Valid password";
else

cout<<"Invalid password";


}

int main()

{

string password;

cout <<"Enter your password"<<endl;

getline(cin,password);

CheckPassword(password);

return 0;

}


Related Solutions

Please make it simply and easy for a beginner to follow.. -Write in C++ -Use Char...
Please make it simply and easy for a beginner to follow.. -Write in C++ -Use Char library functions -Must show that is runs Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties: 1. At least 8 characters long 2. Has at least one upper case letter 3. Has at least one lower case letter 4. Has at least one digit 5. Has at least...
C++ program, I'm a beginner so please make sure keep it simple Write a program to...
C++ program, I'm a beginner so please make sure keep it simple Write a program to read the input file, shown below and write out the output file shown below. Use only string objects and string functions to process the data. Do not use c-string functions or stringstream (or istringstream or ostringstream) class objects for your solution. Input File.txt: Cincinnati 27, Buffalo 24 Detroit 31, Cleveland 17 Kansas City 24, Oakland 7 Carolina 35, Minnesota 10 Pittsburgh 19, NY Jets...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes the character x from string s. For s[] = “America”, a call to deleteSymbol(s, ‘a’) converts s[] = “Ame”
Write in C programming language Write the function replace(char b[], char f[], char t[]). which finds...
Write in C programming language Write the function replace(char b[], char f[], char t[]). which finds the string 'f' in the string 'b' and replaces it with the string 't'. You can assume that f and t same length Example: char string[] = "zap";     replace(string, "ap", "oo"); --changes 'string' to "zoo".     *don't assume substring being replaced is singular, or that its own substrings are unique.     *Don't re scan letters already checked and replaced         char string[] =...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties: 1. At least 8 characters long 2. Has at least one upper case letter 3. Has at least one lower case letter 4. Has at least one digit 5. Has at least on special character
Make a Binary search program for C# and write algorithm and explain it in easy words...
Make a Binary search program for C# and write algorithm and explain it in easy words also show output and input
Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
disadvantages of exports? (please write short and simply)
disadvantages of exports? (please write short and simply)
Please follow this link and listen (OR you can simply search the topic in google, the...
Please follow this link and listen (OR you can simply search the topic in google, the story will pop up in the first result) http://www.npr.org/2014/10/23/358238948/is-there-really-such-a-thing-as-a-trophy-wife Topic : "Is There Really Such A Thing As a ‘Trophy Wife’?" Then write a short response based on the following prompts: • a brief synopsis • key findings • your own analysis or take on the information presented
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in...
JAVA CODE BEGINNER , Please use comments to explain, please Repeat the calorie-counting program described in Programming Project 8 from Chapter 2. This time ask the user to input the string “M” if the user is a man and “W” if the user is a woman. Use only the male formula to calculate calories if “M” is entered and use only the female formula to calculate calories if “W” is entered. Output the number of chocolate bars to consume as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT