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

Write a class called BankAccount that has a string data member called customerNa

ID: 3757909 • Letter: W

Question

Write a class called BankAccount that has a string data member called customerName, a string data member called customerID, and a double data member called customerBalance. The class should have a constructor that takes two strings and a double (name, ID, balance) and uses them to initialize the data members. The data members of this class do not need to be set after they are initialized, so this class doesn't need any set methods - therefore the constructor will directly assign values to the data members instead of calling set methods to do it. The class should have a get method for each data member. It should have a method called withdraw that takes a double parameter and deducts it from the current balance (the balance is allowed to be negative). It should have a method called deposit that takes a double parameter and adds it to the current balance. Your functions should have the following names: getCustomerName getCustomerID getCustomerBalance withdraw deposit

The files must be named: BankAccount.hpp and BankAccount.cpp

Explanation / Answer

#include <iosteram>
using namespace std;

class BankAccount
{
    string customerName;
    string customerID;
    double customerBalance;
public:
    BankAccount(string name,string ID,double balance)
    {
        customerName = name;
        customerID = ID;
        customerBalance = balance;
    }
    string getCustomerName()
    {
        return customerName;
    }
    string getCustomerID()
    {
        return customerID;
    }
    double getCustomerBalance()
    {
        return customerBalance;
    }

    double withdraw(double bal)
    {
        customerBalance = customerBalance - bal;
        return customerBalance;
    }
    double deposit(double bal1)
    {
        customerBalance = customerBalance + bal;
        return customerBalance;
    }  
    void display()
    {
        cout<<"Customer Name is: "<<getCustomerName()<<endl;
        cout<<"Customer Id is: "<<getCustomerID()<<endl;
        cout<<"Customer Balance is: "<<getCustomerBalance()<<endl;
    }
};

int main()
{
    BankAccount obj("Nar", "123", 489.2);
    obj.setViewers(10);
    obj.display();
    return 1;
}

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