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

Write the Code to define a class called BankAccount which can be used to store i

ID: 3855428 • Letter: W

Question

Write the Code to define a class called BankAccount which can be used to store information for a single bank account. The BankAccount class contains two classes, as described below. One class holds information about the depositor. i. the depositor's name, which consists of a first name (like "John") and a last name (like "Public") II. the depositor's Social Security number (e.g., 123-45-6789) The second class holds Information about the bank account itself: I. the account number (e.g., 987654) II. the account balance (e.g., 1234.56) Write a series of class definitions and combine them to create the BankAccount b. Declare an object called myAccount of class BankAccount class c. Assuming that all the components of the myAccount object have been given values, write code to do the following: Test to see if the account number is exactly 234567, if it is, add 250 dollars to the account balance, and then print the last name of the depositor. d. Write a declaration for an array of 100 objects of class BankAccount.

Explanation / Answer

The answer is as follows:

The code is as follows (C++):

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

class Depositor {
   public:
     string firstname;
     string lastname;
     string social_security_num;
};

class Account {
public:
    long num;
    double bal;
   
};

class BankAccount{
    private:
        Depositor dep;
        Account act;
    public:
        void setDepositor(Depositor dp){
             dep = dp;          
        }
        void setAccount(Account at){
             act = at;          
        }
        Depositor getDepositor(){
             return dep;          
        }
        Account getAccount(){
             return act;          
        }
};


void main(){
    BankAccount myAccount;
    BankAccount arrayAcct[100];
    Depositor dep;
    Account act;

    dep.firstname = "John";
    dep.lastname = "Patrick";
    dep.social_security_num = "123-45-6789";
   
    act.num = 234567;
    act.bal = 1234.56;

    myAccount.setDepositor(dep);
    myAccount.setAccount(act);

   
    if (myAccount.getAccount().num == 234567){
        myAccount.getAccount().bal = myAccount.getAccount().bal + 250;
        cout << "Last name:" << myAccount.getDepositor().lastname << endl;
    }     

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote