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

Bank Account should have The following instance variables and related methods ac

ID: 3815059 • Letter: B

Question

Bank Account should have The following instance variables and related methods accountNumber (string) - needs accessor accountType (string) - accessor balance [double] - accessor and mutator customer (Customer *] - accessor and mutator The following instance methods One constructor that takes accountNumber, accountType, and Customer reference In this constructor, make sure to set customer variable to the address of the reference passed in, similar (but not identical) to: class MyClass {AnotherClass* ptr; MyClass::MyClass(AnotherClass& obj) {ptr = &obj;}}; In this constructor, make sure to set the balance to 0. deposit(double amt) method that adds amt to existing balance withdraw(double amt) method that subtracts amt from existing balance transfer(BankAccount& acct, double amt) method that subtracts amt from acct (which is a separate account) and adds that amt to existing balance printInfo() which displays info about the BankAccount (see sample output] Customer should have The following instance variables and related methods id (string) - accessor name (string] - accessor The following instance methods One constructor that takes id and name parameters, and sets them accordingly

Explanation / Answer

Here is code for both class. Please note I have used some format for printinfo as nothing was provioded bu you will be able to easily modify it.

As there was no driver program asked I am not creating any.

#include <iostream>
#include <string>

using namespace std;

class Customer
{
private:
int id;
string name;
public:
Customer(int customerId, int customerName)
{
id = customerId;
name = customerName;
}
  
int getId()
{
return id;
}
  
string getName()
{
return name;
}
};

class BankAccount
{
private:
string accountNumber;
string accountType;
double balance;
Customer *customer;
public:
  
BankAccount(string accNumber, string accType, Customer& c)
{
accountNumber = accNumber;
accountType = accType;
customer = &c;
balance = 0;
}
  
string getAccountNumber()
{   
return accountNumber;
}
  
string getAccountType()
{   
return accountType;
}
  
double getBalance()
{
return balance;
}
  
void setBalance(double b)
{
balance = b;
}
  
Customer* getCustomer()
{
return customer;
}
  
void setCustomer(Customer& c)
{
customer = &c;
}
  
void deposit(double amt)
{
if (amt > 0)
balance += amt;
}
  
void withdraw(double amt)
{
if (balance - amt >= 0)
balance -= amt;
}
  
void transfer(BankAccount& acct, double amt)
{
acct.withdraw(amt);
deposit(amt);
}
  
void printInfo()
{
cout << "Account number: " << accountNumber << endl;
cout << "Account type: " << accountType << endl;
cout << "Id: " << customer->getId() << endl;
cout << "Name: " << customer->getName() << endl;
cout << "Balance: " << balance << endl;
}
};

Please leave positive feedback if this answered this question.

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