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...
Simple code please thats easy to follow. C++ Write a program that can be used to...
Simple code please thats easy to follow. C++ Write a program that can be used to compare Insertion Sort, Merge Sort and Quick Sort. Program must: Read an array size from the user, dynamically an array of that size, and fill the array with random numbers Sort the array with the Insertion Sort, MergeSort and QuickSort algorithms studied in class, doing a time-stamp on each sort. Use your program to measure and record the time needed to sort random arrays...
[ 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
in c++ please follow instructions and fix the errors and please make a comment next to...
in c++ please follow instructions and fix the errors and please make a comment next to each code error you fix. Below are 25 code fragments, inserted into a try catch block. Each line has zero or more errors. Your task is to find and remove all errors in each fragment. Do not fix problems by simply deleting a statement; repair the problems by changing, adding, or deleting a few characters. There may be different ways to fix them You...
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)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT