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

Password Verifier Imagine you are developing a software package for an online sh

ID: 3670378 • Letter: P

Question

Password Verifier

Imagine you are developing a software package for an online shopping site that requires users to enter their own passwords.

Your software requires that users password meet the following criteris:

-The password should be at least six characters long.

-THE PASSWORD SHOULD contain at least one uppercase and at least one lower case letter.

-The password should have at least one digit.

Write a class that verifies that a password meets the stated criteria. Demonstrate the class in a program that allows the user to enter a password and then displays a message indicating whether it is valid or not.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
void main()
{

   char str[20];
   int i,n,n1=0,u=0,l=0,d=0,p=0;

   cout<<"Enter Password";
   cin>>str;

   n=str.length();
   if(n>=6)
   {
       n1=1;
   }


   for(i=0;i<n;i++)
   {
       if(isupper(str[i]))
       {
           u=1;
       }

       if(islower(str[i]))
       {
           l=1;
       }

       if(isdigit(str[i]))
       {
           d=1;
       }

   }
   if(n1==1 && u==1 && l==1 && d==1 )
   {
       cout<<"Password Valid";
   }
   else
   {
       cout<<"Password Invalid";
   }
   getch();
}