Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The code should be in C++ and devided into 3 files a header file and and two cpp

ID: 3765686 • Letter: T

Question

The code should be in C++ and devided into 3 files a header file and and two cpp files.

Project 1: Username and Password Validator

Create a C++ class which, when fed a username and password, can validate that the username and password meets the following criteria:

The username should:

- have at least 8 characters long
- contains only alpha numeric characters (no spaces or special characters)
- contain at least 1 uppercase character
- contain at least 1 lowercase character
- contain at least 1 numeric character (0-9)

The password should:

- not contain a user’s username (i.e. the username “CraigKapp1 is valid, but if that user has the password “CraigKapp1Password”, this password would not be valid because it contains the string “CraigKapp1)
- be at least 8 characters long
- only contain alpha numeric characters (no spaces or special characters)
- contain at least 1 uppercase character
- contain at least 1 lowercase character
- contain at least 1 numeric character (0-9)

HINT: For this assignment, a very useful library of helper functions are available when you say:   #include <cctype>   which is documented for you here.

A number of different program dialogues describe the program I am looking for.

CS52 Username/Password Validator
Username: SmcCorsair1
Password: GoDodgers1
The Username/Password combination is valid!

CS52 Username/Password Validator
Username: SmcCorsair
Password: GoDodgers1
The Username requires numeric character

CS52 Username/Password Validator
Username: smccorsair1
Password: GoDodgers1
The Username requires an uppercase character

CS52 Username/Password Validator
Username: SMCCORSAIR1
Password: GoDodgers1
The Username requires an lowercase character

CS52 Username/Password Validator
Username: corsair
Password: GoDodgers1
The Username requires atleast 8 letters

CS52 Username/Password Validator
Username: SmcCorsair1
Password: aaSmcCorsair1aa
The Password cannot contain the Username

CS52 Username/Password Validator
Username: SmcCorsair1
Password: gododgers1
The Password requires an uppercase character

CS52 Username/Password Validator
Username: SmcCorsair1
Password: GODODGERS1
The Password requires an lowercase character

CS52 Username/Password Validator
Username: SmcCorsair1
Password: Smc1
The Password requires atleast 8 letters


Following the diagrams show below, create the class UsernamePasswordValidator.

UsernamePasswordValidator( );

void setUsername( string username );

void setPassword( string password );
void setUsernameViaCString( char * username );
void setPasswordViaCString( char * password );

void reset( );

bool isValid( );
string reasonForFailure( );

string myUsername;
string myPassword;

bool   my_ValidationFailed;
string my_ReasonWhyItFailed;

UsernamePasswordValidator upv;

string user, pass;
char * badpassword = "data ";
char * goodpassword = "goodPassword1";

cout << "CS52 Username/Password Validator" << endl;
cout << "Username:" << endl;
getline( cin, user ); // reads a whole line of input
cout << "Password:" << endl;
getline( cin, pass ); // reads a whole line of input

upv.setUsername( user );
upv.setPassword( pass );
if (upv.isValid() )
{
cout << "The Username/Password combination is valid!" << endl;
}
else
{
cout << upv.reasonForFailure( ) << endl;
}

upv.reset( );

upv.setUsername( user );
upv.setPassword( badpassword );
if (upv.isValid() )
{
cout << "The Username/Password combination is valid!" << endl;
}
else
{
cout << upv.reasonForFailure( ) << endl;
}

UsernamePasswordValidator Sample Driver Code UsernamePasswordValidator

UsernamePasswordValidator( );

void setUsername( string username );

void setPassword( string password );
void setUsernameViaCString( char * username );
void setPasswordViaCString( char * password );

void reset( );

bool isValid( );
string reasonForFailure( );

string myUsername;
string myPassword;

bool   my_ValidationFailed;
string my_ReasonWhyItFailed;

UsernamePasswordValidator upv;

string user, pass;
char * badpassword = "data ";
char * goodpassword = "goodPassword1";

cout << "CS52 Username/Password Validator" << endl;
cout << "Username:" << endl;
getline( cin, user ); // reads a whole line of input
cout << "Password:" << endl;
getline( cin, pass ); // reads a whole line of input

upv.setUsername( user );
upv.setPassword( pass );
if (upv.isValid() )
{
cout << "The Username/Password combination is valid!" << endl;
}
else
{
cout << upv.reasonForFailure( ) << endl;
}

upv.reset( );

upv.setUsername( user );
upv.setPassword( badpassword );
if (upv.isValid() )
{
cout << "The Username/Password combination is valid!" << endl;
}
else
{
cout << upv.reasonForFailure( ) << endl;
}

Explanation / Answer

#include "stdafx.h" #include #include #include #include "ctype.h" using namespace std; // Function prototype bool lengthTest(char *); bool lowCaseTest(char []); bool upCaseTest(char []); bool digitTest(char []); const int SIZE = 20; int main() { // Buffer to hold the string. char password[SIZE]; int sumofbool; // Program Intro Display cout