Given following code and write comments for those code
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#define MAX_PASSWORD_LENGTH 128
#define MIN_PASSWORD_LENGTH 10
#define ALLOW_PASSPHRASE true
#define MIN_PHRASE_LENGTH 20
#define OPTIONAL_TESTS_REQUIRED true
#define MIN_OPTIONAL_TESTS_TO_PASS 4
bool isStrongPassword(char *password);
void printTestResults(char *password, bool isPassphrase, int optionalTestsPassed);
int main() {
char passwords[][128] = {
"password",
"mypassword",
"thisismypassword",
"passssword",
"This is my password phrase1",
"Tinypw1",
"Ireallydontlikehavingtomakeupnewpasswordsallthetime1",
"Iloveyouxxxooo1",
"Boom**********!",
"IHATEPWORDS1!",
"ihatepwords1!",
"IHatePwords!",
"IHatePwords",
"my pass phrase does not need to pass tests",
"short pass phrase",
"x",
"x1",
"Zxcvbnmnas7",
"Zxcvbnmnas~",
"Zxcvbnmnas7~"
};
for (int i = 0; i < sizeof(passwords) / sizeof(passwords[0]); ++i) {
bool isPassphrase = strchr(passwords[i], ' ') && strlen(passwords[i]) >= MIN_PHRASE_LENGTH;
int optionalTestsPassed = 0;
if (OPTIONAL_TESTS_REQUIRED) {
if (strpbrk(passwords[i], "abcdefghijklmnopqrstuvwxyz")) {
optionalTestsPassed++;
}
}
bool isPasswordStrong = isStrongPassword(passwords[i]) &&
(isPassphrase || optionalTestsPassed >= MIN_OPTIONAL_TESTS_TO_PASS);
printTestResults(passwords[i], isPassphrase, optionalTestsPassed);
printf("Strong? : %s\n", isPasswordStrong ? "true" : "false");
printf("Total optional tests passed: %d\n", optionalTestsPassed);
printf("\n");
}
return 0;
}
bool isStrongPassword(char *password) {
if (strlen(password) < MIN_PASSWORD_LENGTH) {
return false;
}
if (strlen(password) > MAX_PASSWORD_LENGTH) {
return false;
}
for (int i = 0; i < strlen(password) - 2; ++i) {
if (password[i] == password[i + 1] && password[i + 1] == password[i + 2]) {
return false;
}
}
return true;
}
void printTestResults(char *password, bool isPassphrase, int optionalTestsPassed) {
printf("Proposed password: %s\n", password);
printf("Failed Tests : ");
if (strlen(password) < MIN_PASSWORD_LENGTH) {
printf("[1] ");
}
if (strlen(password) > MAX_PASSWORD_LENGTH) {
printf("[2] ");
}
for (int i = 0; i < strlen(password) - 2; ++i) {
if (password[i] == password[i + 1] && password[i + 1] == password[i + 2]) {
printf("[3] ");
break;
}
}
printf("\n");
printf("Passed Tests : ");
if (strlen(password) >= MIN_PASSWORD_LENGTH && strlen(password) <= MAX_PASSWORD_LENGTH &&
!(strlen(password) > MIN_PHRASE_LENGTH && isPassphrase)) {
printf("[1-3] ");
}
if (optionalTestsPassed >= MIN_OPTIONAL_TESTS_TO_PASS || !OPTIONAL_TESTS_REQUIRED) {
printf("[4-7] ");
}
printf("\n");
printf("Required Test Errors : [\n");
if (strlen(password) < MIN_PASSWORD_LENGTH) {
printf("'The password must be at least %d characters long.'\n", MIN_PASSWORD_LENGTH);
}
if (strlen(password) > MAX_PASSWORD_LENGTH) {
printf("'The password must be fewer than %d characters.'\n", MAX_PASSWORD_LENGTH);
}
for (int i = 0; i < strlen(password) - 2; ++i) {
if (password[i] == password[i + 1] && password[i + 1] == password[i + 2]) {
printf("'The password may not contain a sequence of three or more repeated characters.'\n");
break;
}
}
printf("]\n");
printf("Optional Test Errors : [\n");
if (OPTIONAL_TESTS_REQUIRED) {
if (!(strpbrk(password, "abcdefghijklmnopqrstuvwxyz"))) {
printf("'The password must contain at least one lowercase letter.'\n");
}
}
printf("]\n");
printf("Is a Pass phrase : %s\n", isPassphrase ? "true" : "false");
}
to generate a solution
a solution
- In C++, using STL algorithms create a program that allows the user to search the text file for a price, and return all items for the inputted price. Console: Enter the command: cin>> search What price do you want to search for? cin>> $10 cout << "The following flavors are $10 " << flavor << flavor << endl; --------------------------------------------------------------------- Strawberry and rainbow should be returned for $10 If no flavor is $10: cout<<"Sorry, that price is not available"; Provided text file: icecream.txt chocolate $15 strawberry $10 vanilla $13 rainbow $10arrow_forwardUsing Payton (write it as simple as possible)arrow_forwardHome B Announcements - IT-140-J6182 zy Section 2.1 - IT 140: Introduction b Answered: Type two statements. X 8 https://learn.zybooks.com/zybook/SNHUIT140V3/chapter/2/section/1 = zyBookS My library > IT 140: Introduction to Scripting v3 home > 2.1: String basics E zyBooks catalog ? Help/FAQ 8 Jose Roque CHALLENGE 2.1.2: Concatenating strings. АCTIVITY Write two statements to read in values for my_city followed by my_state. Do not provide a prompt. Assign log_entry with current_time, my_city, and my_state. Values should be separated by a space. Sample output for given program if my_city is Houston and my_state is Texas: 2014-07-26 02:12:18: Houston Texas Note: Do not write a prompt for the input values. 247772.2002516.qx3zgy7 1 current_time = '2014-07-26 02:12:18:' 2 my_city =" 3 my_state = " 4 log_entr 1 test passed = '" 6 '' Your solution goes here '" All tests 7 passed 8 print(log_entry) Activate Windows Go to Settings to activate Windows. 6:36 AM P Type here to search O 81°F Partly…arrow_forward
- SyntaxError: invalid syntax (<string>, line 56)arrow_forwardA word Decrambling game using srand() for descrambling these words: "Screen, Programming, Command, Definition." The game should be timed for 1 minute or 30 seconds using the <ctime> library. Should allow for user input to be able to guess...arrow_forwardAssembely: What does this code produce? FOR varName,<monday,tuesday,wednesday,thursday,friday> DWORD varName<> ENDMarrow_forward
- modifying following code and write comments for each line of codes. #include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <string.h> #define MAX_PASSWORD_LENGTH 128#define MIN_PASSWORD_LENGTH 10#define ALLOW_PASSPHRASE true#define MIN_PHRASE_LENGTH 20#define OPTIONAL_TESTS_REQUIRED true#define MIN_OPTIONAL_TESTS_TO_PASS 4 bool isStrongPassword(char *password);void printTestResults(char *password, bool isPassphrase, int optionalTestsPassed); int main() { char passwords[][128] = { "password", "mypassword", "thisismypassword", "passssword", "This is my password phrase1", "Tinypw1", "Ireallydontlikehavingtomakeupnewpasswordsallthetime1", "Iloveyouxxxooo1", "Boom**********!", "IHATEPWORDS1!", "ihatepwords1!", "IHatePwords!", "IHatePwords", "my pass phrase does not need to pass tests", "short pass phrase", "x", "x1",…arrow_forwardTrue or False _(1) The expression n/3*(8+4) evaluates to 16 if n=4 ___(2) x is greater than both y and z can be written as the statement x>y&&z ; in Java. ___(3) In Java a string is automatically an object.arrow_forwardHello, I am having trouble with this code in c++ for my advance data structure course . I am using the onlinegdb.com complier and get this small issue. I have provided both the snip of the result as well as the code. main.cpp #include<iostream>#include"Student.h"#include<iostream>#include "Student.h"#include "Faculty.h"using namespace std; int main(){ Student std("John","Smith",3.75,"Spring 2019"); Faculty faculty("Mary","Smith","2019"); cout<<"===========================================\n"; faculty.Print(); cout<<"===========================================\n"; cout<<"\n\n\n"; cout<<"===========================================\n"; std.Print(); cout<<"===========================================\n"; return 0;} Person.h ifndef PERSON_H#define PERSON_H#include<iostream>#include<string>using namespace std;class Person{private: int personID; string firstName; string lastName;public: Person(string fName,…arrow_forward