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

Write a C++ program for the following . Password Verifier Imagine you are develo

ID: 3873671 • Letter: W

Question

Write a C++ program for the following .

Password Verifier

Imagine you are developing a software package that requires users to enter their own passwords. Your software requires that users' passwords meet the following criteria:

The password should be at least 6 characters long.

The password should contain at least one uppercase and at least one lowercase letter.

The password should have at least 1 digit.

Write a program that asks for a password and then verifies that it meets the stated criteria. If it doesn't the program should display a message telling the user why.

Expected Output

When your solution is executed, it must match, verbatim, the following output, depending upon the use case:

User accepts auto-generated password

User changes password successfully

User changes password unsuccessfully

Algorithm for auto-generated passwords

The auto-generated passwords are generated from the user's name as follows:

The user's name is reversed, removing any white space or period characters ('.')

If the user entered their name in all uppercase or all lower case, the algorithm treats the name as if it were entered with the proper case as shown in the above examples.

The length of the name entered -- including any white space and punctuation -- is appended to the end of the auto-generated password.

If the user entered a name that is less than 6 characters, the number 6 is appended to the end of the reversed name until the password is 6 characters long.

Explanation / Answer

CODE :

#include<iostream.h>

#include<string.h>

#include<conio.h>

#include<ctype.h>

#include<stdio.h>

class password

{

char name[30];

char psswd[30];

public:

void assign();

void check(char str[]);

};

void password :: assign()

{

cout<<" Enter your full name , including middle intial : ";

gets(name);

char str[30];

int i,j,k[2],s=0;

for(i=strlen(name)-1,j=0;i>=0;i--)

{

if(name[i]==' ')

continue;

if((name[i]>='a' && name[i]<='z') || (name[i]>='A' && name[i]<='Z'))

{

str[j]=name[i];

j++;

}

}

i=strlen(name);

cout<<" "<<i;

while(i!=0)

{

k[s++]=i%10;

i=i/10;

}

i=strlen(name);

if(i<10)

str[j++]=k[0]+48;

if(i>=10)

{ str[j++]=k[1]+48;

str[j++]=k[0]+48;

}

if(j-1<6)

{

while(j!=6)

str[j++]='6';

}

str[j]='';

strcpy(psswd,str);

cout<<" Your auto-generated password is: ";

puts(psswd);

cout<<" Would you like to change your password now [Y][N]? ";

char ch;

cin>>ch;

if(ch=='N' || ch=='n')

cout<<" Thank you. It is recommended that you change your password the next time you log into our system.";

else if(ch=='Y' || ch=='y')

{

cout<<" Enter your password : ";

gets(str);

check(str);

}

}

void password :: check(char str[30])

{

int i=0;

int flag[4]={1,0,0,0};

if(strlen(str)<6)

flag[0]=0;

for(i=0;str[i]!='';i++)

{

if(isupper(str[i]))

flag[1]=1;

if(islower(str[i]))

flag[2]=1;

if(isdigit(str[i]))

flag[3]=1;

}

if(flag[0]==1 && flag[1]==1 && flag[2]==1 && flag[3]==1)

{

cout<<" Thank you. Please use your new password the next time you log into our system.";

strcpy(psswd,str);

}

else

{

cout<<" We're sorry. Your password does not meet our requirements.";

if(flag[0]==0)

cout<<" * Your password should be atleast 6 characters long.";

if(flag[1]==0 || flag[2]==0)

cout<<" * Your password does not contain at least one uppercase and one lowercase letter.";

if(flag[3]==0)

cout<<" * Your password does not contain at least 1 digit.";

cout<<" Your password was not changed; it remains: ";

cout<<psswd;

cout<<" As a remainder, your password should ";

cout<<" * be at least 6 characters long";

cout<<" * contain at least one uppercase and at least one lowercase letter";

cout<<" * contain at least 1 digit";

cout<<" It is recommended that you change your password the next time you log into our system.";

}

}

void main()

{

clrscr();

password P;

P.assign();

getch();

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote