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

QUESTION: Create a class and name it Person, this class should include the follo

ID: 3814067 • Letter: Q

Question

QUESTION: Create a class and name it Person, this class should include the following data members: · Last name · First name · Zip code. Choose a proper data type for each member. Include a default constructor that initializes last name, first name, and zip code. Also include an argument constructor. Include a function to display the date members. Create another class and named SavingAccount. Provide fields for the customer (use the Person class), accountNumber and balance. Provide two constructors, a default constructor and an argument constructor. Include a function that displays an account’s data fields. Include the following methods as member of the SavingAccount class: Deposit and Withdraw methods, each method has an integer argument and should update the balance member. Instantiates two SavingAccount objects using both constructor and test all the methods. Also, use Member Initialization List (MIL) whenever it’s possible. Make sure to include destructors for both classes. QUESTION: Create a class and name it Person, this class should include the following data members: · Last name · First name · Zip code. Choose a proper data type for each member. Include a default constructor that initializes last name, first name, and zip code. Also include an argument constructor. Include a function to display the date members. Create another class and named SavingAccount. Provide fields for the customer (use the Person class), accountNumber and balance. Provide two constructors, a default constructor and an argument constructor. Include a function that displays an account’s data fields. Include the following methods as member of the SavingAccount class: Deposit and Withdraw methods, each method has an integer argument and should update the balance member. Instantiates two SavingAccount objects using both constructor and test all the methods. Also, use Member Initialization List (MIL) whenever it’s possible. Make sure to include destructors for both classes. QUESTION: Create a class and name it Person, this class should include the following data members: · Last name · First name · Zip code. Choose a proper data type for each member. Include a default constructor that initializes last name, first name, and zip code. Also include an argument constructor. Include a function to display the date members. Create another class and named SavingAccount. Provide fields for the customer (use the Person class), accountNumber and balance. Provide two constructors, a default constructor and an argument constructor. Include a function that displays an account’s data fields. Include the following methods as member of the SavingAccount class: Deposit and Withdraw methods, each method has an integer argument and should update the balance member. Instantiates two SavingAccount objects using both constructor and test all the methods. Also, use Member Initialization List (MIL) whenever it’s possible. Make sure to include destructors for both classes.

Explanation / Answer

#include <iostream>
using namespace std;

class Person
{
  
   private:
   string lastName;
   string firstName;
   int zipCode;

   public:
   Person()//default constructor
   {
       lastName = " ";
       firstName = " ";
       zipCode = 0;
   }
   Person(string lastName,string firstName,int zipCode) //argument constructor
   {
       this->lastName = lastName;
       this->firstName = firstName;
       this->zipCode = zipCode;
   }


    void display()
    {
        cout<<" First Name : "<<firstName;
        cout<<" Last Name : "<<lastName;
        cout<<" ZipCode : "<<zipCode;
      
    }
    ~Person() //destructor
    {
        cout<<" Destructing person";
    }
  
};


class SavingAccount
{
    private:
    Person p;
    int accountNumber;
    double balance;
  
    public:
    SavingAccount() //default constructor
    {
        accountNumber = 0;
        balance = 0;
    }
    SavingAccount(Person p,int accountNumber,double balance)//argument constructor
    {
        this->p = p;
        this->accountNumber = accountNumber;
        this->balance = balance;
      
    }
  
    void display()
    {
        cout<<" Account Number : "<<accountNumber;
        cout<<" Balance : "<<balance;
    }
    void deposit(double amount)
    {
        balance = balance + amount;
    }
    void withdraw(double amount)
    {
        balance = balance - amount;
    }
    ~SavingAccount()//destructor
    {
        cout<<" Destructing Saving Account";
    }
};
int main()
{
    Person p1("John","Marker",120003);
   SavingAccount sa1(p1,100567,677.50);
  
   sa1.display();
   sa1.deposit(210);
   sa1.display();
  
   Person p2("Catherina","Lewis",127001);
   SavingAccount sa2(p2,100455,433.50);
  
   sa2.display();
   sa2.withdraw(120);
   sa2.display();
  
  
  
  
   return 0;
}


Output:

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