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

THIRD TIME POSTING THIS. write a c++ program that will prompt a user to enter a

ID: 3936921 • Letter: T

Question

THIRD TIME POSTING THIS.

write a c++ program that will prompt a user to enter a username and password. Validate the user’s login before allow the use to advance.

You must start out by having a datafile that has a list of ten (10) usernames and passwords.

   Possible login error messages for username:

1. Username not found

Possible login error messages for password:

1. Password not found

1. Password must contain eight (8) or more characters

2. Password must contain a special character

3. Password cannot have blank spaces

4. Password must have at least two numbers

5. Password must have at least one uppercase letter

The program should prompt a user with a login screen. (Example)

Enter Login ID: XXXXXXXXXX

(if login is not found, display error message and loop until correct of the user chooses to exit.)

Then

   Enter Password: XXXXXXXXXXXXX

   (If the password not found, display error message and loop twice. If not successful after two attempts, write a login attempt log to a log file named “ERROR_LOG”.

If login attempt is successful, prompt the user with the following screen:

1. Add a User & Password

2. Update user password

3. Exit

Enter your choice: __

*Make use of the cctype header

Explanation / Answer

#include <iostream>
#include <cctype>
using namespace std;

//function prototype for testing.
bool PasswordClient(char [], int);
int main()
{
//allocate memory
char *passwrd;  
int lnj;   //assure requested lnj and pass lnj are the same
int nochars;   //hold number of characters for passwrd

//get Password from user
cout << "Please enter how many characters you would like your password to be.";
cout << " Your passwrd must be at least 6 characters long." << endl;
cin >> nochars;


while (nochars < 6)
{
cout << "Please enter a passwrd lnj of at least 6 characters." << endl;
cin >> nochars;
}


passwrd = new char[nochars];


cout << "Please enter a passwrd that contains at least one uppercase letter, ";
cout << "one lowercase letter, and at least one digit." << endl;


cin >> passwrd;


lnj = strlen(passwrd);


while (lnj != nochars)
{
cout << "Your passwrd is not the size you requested. ";
cout << "Please re-enter your passwrd." << endl;
cin >> passwrd;
lnj = strlen(passwrd);
}

if (PasswordClient(passwrd, nochars))
cout << "Your passwrd is valid." << endl;
else
{
cout << "Your passwrd is not valid. ";
cout << "Please refer to the above warning message." << endl;
}
return 0;
}

bool PasswordClient(char pass[], int nochars)
{
int count = 0;

while (pass[count] != islower && pass[count] != '')
count++;

if (!islower(pass[count]))
return false;

return true;
}