accept user name and password and check whether it contain a degit or not

#include <iostream>
#include<string>
using namespace std;
class auth
{
  public:
  int l,i,p,k=0;
    string uname,password;
    void get()
    {
    cout<<"input user name:";
    cin>>uname;
    cout<<"input password:";
    cin>>password;
    }
    void calculate()
    {
         l=password.size();
    for(i=0;i<l;i++)
    {
      
       if(isdigit (password[i])!=0)
       {
         k++;
         break;
       }
      
    }
    }
    void show()
    {
        try
    {
      if(l<6)
      {
        throw"password less than 6";
      }
      else if  (k==0)
      {
        throw "no digit";
      }
      else
      {
        throw "password generated";
      }
     
    
    }
     catch(const char *msg)
      {
         cout<<msg;
      }
    }
};
int main()
{
  auth obj;
  obj.get();
  obj.calculate();
  obj.show();

} OUTPUT:

motionhdmoviz.com


0 comments: