Design a BankAccount class (Links to an external site.) that has the following member variables (Links to an external site.): • custName: a string • balance: a double
The class (Links to an external site.) should have the following member functions:
• Default Constructor (Links to an external site.). A default constructor (Links to an external site.) that sets custName as empty string and balance as 0. • Constructor (Links to an external site.). Accepts the custName and balance as arguments (Links to an external site.).
• setCustName. A mutator function for the custName variable (Links to an external site.).
• getCustName. An accessor function for the custName variable (Links to an external site.).
• setBalance. A mutator function for the balance variable (Links to an external site.).
• getBalance. An accessor function for the balance variable (Links to an external site.).
• deposit(double amount). Add the deposit amount passed in to the balance, assume the amount is not negative.
• withdrawal(double amount). Subtract the withdrawal amount from the balance. Assume the amount is not negative and is not greater than the balance.
Create an instance/object of BankAccount class using default constructor. Set the balance and customer name. Add $100 deposit by calling the deposit method. Subtract $50 withdrawal by calling the the withdrawal method. Display customer name and final balance.
C++ CODE:
#include <iostream>
#include <string>
using namespace std;
class BankAccount{
private:
string custName;
double balance;
public:
// Default constructor
BankAccount() : custName(""), balance(0) {}
// Constructor
BankAccount(string name, double bal) : custName(name), balance(bal) {}
// Accessor
string getCustName() const {
return custName;
}
// Mutator
void setCustName(string custName) {
this->custName = custName;
}
// Accessor
double getBalance() const {
return balance;
}
// Mutator
void setBalance(double balance) {
this->balance = balance;
}
// Method to deposit amount
void deposit(double amount) {
this->balance += amount;
}
// Method to withdraw amount
void withdraw(double amount) {
this->balance -= amount;
}
};
int main(){
BankAccount b;
b.setBalance(150.0);
b.setCustName("John Doe");
b.deposit(100.0);
b.withdraw(50.0);
cout << "Customer name: " << b.getCustName() << endl;
cout << "Final balance: $" << b.getBalance() << endl;
return 0;
}
OUTPUT:

FOR ANY HELP JUST DROP A COMMENT
Design a BankAccount class (Links to an external site.) that has the following member variables (Links...