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

c++ using eclipse Define the class bankAccount to implement the basic properties

ID: 3885792 • Letter: C

Question

c++ using eclipse

Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder's name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 components of type bankAccount to process up to 10 customers and write a program to illustrate how to use your class.

Explanation / Answer

#include<iostream>
#include<string>
#include<sstream>

using namespace std;

class bankAccount {
   private:
        string name;
        double balance;
        double intrest_rate;
        int acc_no;
        static int code;
   public:
        bankAccount(){
            code++;
            acc_no = code;
            balance = 0;
        }
        void setName(string a ){
             name = a;
        }
        void setBalance(double a ){
             balance = a;
        }
        void setIntrest(double a ){
             intrest_rate = a;
        }
        string getName(){
             return name;
        }
        double getBalance(){
             return balance;
        }
        double getIntrest(){
             return intrest_rate;
        }
        void deposit(double a ){
             balance = balance + a;
        }
        void withdrawl(double a ){
           if (a < balance)
               balance = balance - a;
           else
              cout << "Insufficient funds ";
        }
        void disp(){
           cout << acc_no << " " << name << " " << balance << " " << intrest_rate << endl;
        }

};

int bankAccount::code = 0;
int main(){

    bankAccount bank[10];
   


    for (int i=0; i<10; i++){
       ostringstream str1;
       str1 << i;
       bank[i].setName("name" + str1.str());
       bank[i].setBalance(100000 + i);
       bank[i].setIntrest(5.6+i);
    }

    for (int i=0; i<10; i++){
       cout << "-------------------------------- ";
       bank[i].disp();
    }
   
    
}

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