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

3.Create a class called Password that represents the password for a user account

ID: 3667966 • Letter: 3

Question

3.Create a class called Password that represents the password for a user account. The class should have at least one string data member representing the password and the following member functions: A constructor that creates an empty password. Get function that returns the current password. Set function that changes the current password to a given string. This function should not change the password if the new string is less than 8 characters in length or if the new string is the same as the previously set password. A new data member may be required to implement this.

I need this in C++ not java.

Explanation / Answer

#include<iostream.h>
#include<string.h>

class Password
{
public:
   char password[20];

   Password()
   {
       password="";
   }

   char[] get()
   {
       return password;
   }

   void set(char[] p)
   {
       int a=strcmp(password,p)
       if(strlen(p)<8 || a==0)
       {
           cout<<"No Password change";
       }
       else
       {
           strcpy(password,p);
       }
   }
};

  

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