Question

Q3

A)Define the class bankAccount to store a bank customer's account number and balance .
Suppose that account number is of type int m and balance is of type double . Your class should at least , provide the account number m retrive the balance , depositand withdraw money , and print account information. Add appropriate constructors.

B) Every bank offers a checking account . Drive the class checkingAccount from the class bankAccount( design in part (a).This class inherits member to store theaccount number and the balance from the base class. A customer with a checking account typically receives interest , maintains a minimum balance , and pays servicecharges if the balance falls below the minimum balance . Add member variables to store this additional information . In addition to the opreation inherited from thebase class , this class should provide the following opreation : set interest rate, retrieve interest ratem, set minimum balance, retrieve minimum balance, set servicecharges, retrieve service charges, post interest, verify if the balance is less than the minimum balance , write a check , withdraw(override the method of the baseclass), and print account information. Add appropriate constructors.
c. Every bank offers a savings account .Derive the class savingsAccount from the class bankAccount(designed in part (a)).This class inherits members to store theaccount number and the balance from the base class.A customer with a savings account typically receives interest, makes deposits, and withdraws money.In addition tothe operations inherited from the base class, this class should provide the foolowing operations:set interest rate, retrieve interest rate, post interest, withdraw(override the method of the base class), and print account information. Add appropriate constructors.
Write a program to test your classes designed in parts (b) and (c).By C++.
1 0
Add a comment Improve this question Transcribed image text
Answer #1

please rate - thanks

#include
#include
using namespace std;
class bankAccount
{public:
    bankAccount(int,double);   
    void setAccNum(int);
    int getAccNum();
    double getBalance();
    void withdraw(double);
    void deposit(double);
    void print();
protected:
    int accNum;
    double balance;
};
class savingsAccount: public bankAccount
{public:
    savingsAccount(int,double);
    void setRate(double);  
    double getRate();
    void withdraw(double);
    void postInterest();
    void savingsAccount::print();
protected:
    double rate;
};
class checkingAccount: public bankAccount
{
public:
    checkingAccount(int accNum,double bal);  
    double getMinBal();
    double getRate();
    double getFee();
    void setMinBal(double);   
    void setRate(double);   
    void setFee(double);
    void postInterest();
    bool checkMinBal(double);
    void checkingAccount::writeCheck(double);
    void withdraw(double);
    void print();
protected:
    double rate,minBal,fee;
};
bankAccount::bankAccount(int n,double b)
{accNum=n;
balance=b;
}
void bankAccount::setAccNum(int a)
{accNum=a;
}
int bankAccount::getAccNum()
{return accNum;
}
double bankAccount::getBalance()
{return balance;
}
void bankAccount::withdraw(double a)
{balance-=a;
}
void bankAccount::deposit(double a)
{balance+=a;
}
void bankAccount::print()
{cout< }
checkingAccount::checkingAccount(int n,double b):bankAccount(n,b)
{setRate(.04);
setMinBal(500);
setFee(20);
}
double checkingAccount::getMinBal()
{return minBal;
}
double checkingAccount::getRate()
{return rate;
}
double checkingAccount::getFee()
{return fee;
}
void checkingAccount::setMinBal(double m)
{minBal=m;
}
void checkingAccount::setRate(double r)
{rate=r;
}
void checkingAccount::setFee(double f)
{fee=f;
}
void checkingAccount::postInterest()
{balance+=(balance*rate);
}
bool checkingAccount::checkMinBal(double a)
{if(balance-a>=minBal)
       return true;
else
       return false;
}
void checkingAccount::writeCheck(double a)
{withdraw(a);
}
void checkingAccount::withdraw(double a)
{if(balance-a<0)
     cout<<"insufficient funds for $"< else if(balance-a      if(balance-a-fee         cout<<"insufficient funds for withdrawal + fees, since balance will be below minimum\n";
     else
        {cout<<"balance below minimum. $"<          balance-=(a+fee);
        }
else
    balance-=a;
}
void checkingAccount::print()
{cout<<"Interest Checking ACCT#:\t"<      <<"\tBalance: $"< }
savingsAccount::savingsAccount(int n,double b):bankAccount(n,b)
{setRate(.06);
}
double savingsAccount::getRate()
{return rate;
}
void savingsAccount::setRate(double r)
{rate=r;
}
void savingsAccount::withdraw(double a)
{if(balance-a<0)
   cout<<"insufficient funds for $"< else
balance-=a;
}
void savingsAccount::postInterest()
{balance+=(balance*rate);
}
void savingsAccount::print()
{cout<<"Savings ACCT#:\t\t\t"<       <<"\tBalance: $"< }
int main()

{    
checkingAccount a(1234,1000);  
checkingAccount b(5678, 450);  
savingsAccount c(91011, 9300);    
savingsAccount d(121314, 32);
a.deposit(1000);  
b.deposit(2300);    
c.deposit(800);    
d.deposit(500);
a.postInterest();  
b.postInterest();
c.postInterest();  
d.postInterest();
a.print();    
b.print();  
c.print();
d.print();    
a.writeCheck(250);  
b.writeCheck(350);    
c.withdraw(120);    
d.withdraw(290);
a.print();  
b.print();  
c.print();  
d.print();  
system("pause");
return 0;
}

Add a comment
Answer #2

Dear,

#include

using namespace std;

class BankAccount

{

public:

       int accountNumber;

       double balance;

      

public:

             

       BankAccount(int ano,double bal)

       {

              accountNumber=ano;

              balance=bal;

       }

       BankAccount()

       {

       }

public:

       double getBalance()

       {

              return(balance);

       }

       int getAccountNumber()

       {

              return(accountNumber);

       }

       void setBalance(double amount)

       {

              balance=amount;

       }

       void setAccountNumber(int ano)

       {

              accountNumber=ano;

       }

       void virtual showAccountInfo()

       {

              cout<<"Account Number :"<

              cout<<"Account Balance:"<

       }

       double virtual depositAmount(double damount)

       {

              balance=balance+damount;

              return(balance);

       }

       double virtual withDrawAmount(double wamount)

       {

              balance=balance-wamount;

              return(balance);

       }

};

class CheckingAccount : BankAccount

{

       double interest;

       double minBal;

       double serviceCharge;

public:

       CheckingAccount(int _ano,double _amount,double _interest):BankAccount(_ano,_amount)

       {

              interest=_interest;

              minBal=500;//By default

       }

       void setInterestRate(double irate)

       {

              interest=irate;

       }

       double retrieveInterestRate()

       {

              return(interest);

       }

       void setMinBal(double mbal)

       {

              minBal=mbal;

       }

       double retrieveMinBal()

       {

              return(minBal);

       }

       void setServiceCharge(double scharge)

       {

              serviceCharge=scharge;

       }

       double retrieveServiceCharge()

       {

              return(serviceCharge);

       }

       double depositAmount(double damount)

       {

              balance=balance+damount;

              return(balance);

       }

       double withDrawAmount(double wamount)

       {

              if(check())

                     balance=balance-wamount;

              else

                     cout<<"you have in sufficient balance"<

              return(balance);

       }

       bool check()

       {

              if(balance

                     return(false);

              else

                     return(true);

       }

       void showAccountInfo()

       {

              cout<<"Account Number :"<

              cout<<"Account Balance:"<

       }

};

class SavingAccount:BankAccount

{

       double minBal;

public:

       SavingAccount(int _ano,double _amount):BankAccount(_ano,_amount)

       {

              minBal=500;

       }

       double depositAmount(double damount)

       {

              balance=balance+damount;

              return(balance);

       }

       double withDrawAmount(double wamount)

       {

              if(check())

                     balance=balance-wamount;

              else

                     cout<<"you have in sufficient balance"<

              return(balance);

       }

       void setMinBal(double mbal)

       {

              minBal=mbal;

       }

      

       bool check()

       {

              if(balance

                     return(false);

              else

                     return(true);

       }

       void showAccountInfo()

       {

              cout<<"Account Number :"<

              cout<<"Account Balance:"<

       }

};

int main()

{

       double amount;

       int choice;

       do

       {

       cout<<"Create an Account"<

       cout<<"1 Checking Account"<

       cout<<"2 Saving Account"<

       cout<<"3 Exit"<

      

       cin>>choice;

      

       if(choice==1)

       {

       cout<<"enter account number";

                     int ano;

                     cin>>ano;

                     cout<

                     double obal;

                     cin>>obal;

                     double irate;

                     cout<

                     cin>>irate;

                     CheckingAccount obj(ano,obal,irate);

                     int ch;

                     do

                     {

                           cout<<"1 Deposit"<

                          

                           cin>>ch;

                           switch(ch)

                           {

                           case 1:

                                  cout<<"Enter amount";

                                  cin>>amount;

                                  double damount;

                                  damount=obj.depositAmount(amount);

                                  cout<<"Available balance: "<

                                  break;

                           case 2:

                                  cout<<"Enter amount";

                                  cin>>amount;

                                  double wamount;

                                         wamount=obj.withDrawAmount(amount);

                                  cout<<"Available balance: "<

                                  break;

                           case 3:

                                  obj.showAccountInfo();

                                  break;

                          

                           }

                     }while(ch!=4);

       }

       else if(choice==2)

       {

      

                     cout<<"enter account number";

                     int _ano;

                     cin>>_ano;

                     cout<

                     double _obal;

                     cin>>_obal;

                     double _irate;

                     cout<

                     cin>>_irate;

                     SavingAccount sObj(_ano,_obal);

                     int _ch;

                     do

                     {

                           cout<<"1 Deposit"<

                          

                           cin>>_ch;

                           switch(_ch)

                           {

                           case 1:

                                  cout<<"Enter amount";

                                  cin>>amount;

                                  double _damount;

                                         _damount=sObj.depositAmount(amount);

                                  cout<<"Available balance: "<<_damount;

                                  break;

                           case 2:

                                  cout<<"Enter amount";

                                  cin>>amount;

                                  double _wamount;

                                  _wamount=sObj.withDrawAmount(amount);

                                  cout<<"Available balance: "<<_wamount;

                                  break;

                           case 3:

                                  sObj.showAccountInfo();

                                  break;

                           case 4:break;

                           default:cout<"invalid choice";break;

                           }

                     }while(_ch!=4);

       }

             

      

       }while(choice!=3);

}



uploaded image

Add a comment
Know the answer?
Add Answer to:
Q3
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Simple code please Thank you in advance B. Write a C++ program as per the...

    C++ Simple code please Thank you in advance B. Write a C++ program as per the following specifications: a. Define the class BankAccount to store a bank customer's account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank...

  • This is in C++ (using IDE Visual Studio). I am seeking assistance ASAP. Please include a...

    This is in C++ (using IDE Visual Studio). I am seeking assistance ASAP. Please include a static member in the class to automatically assign account numbers (used to process up to 10 accounts) and have the user include their first and last name. Thank you! 13. a. Define the class bankAccount to store a bank customer's account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide...

  • 14 b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount...

    14 b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class inherits members to store the account number and the balance from the base class. A customer with a checking account typically receives interest, maintains a minimum balance, and pays service charges if the balance falls below the minimum balance. Add member variables to store this additional information. In addition to the operations inherited from the base class, this...

  • c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one...

    c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance but has a higher interest rate (the benefit here being larger growth in this type of account). Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge, limited check writing, no minimum balance, and no interest; another with no...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • c++ please    Define the class bankAccount to implement the basic properties of a bank account....

    c++ please    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 func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...

  • In this, you will create a bank account management system according to the following specifications: BankAccount...

    In this, you will create a bank account management system according to the following specifications: BankAccount Abstract Class contains the following constructors and functions: BankAccount(name, balance): a constructor that creates a new account with a name and starting balance. getBalance(): a function that returns the balance of a specific account. deposit(amount): abstract function to be implemented in both Checking and SavingAccount classes. withdraw(amount): abstract function to be implemented in both Checking and SavingAccount classes. messageTo Client (message): used to print...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter...

    Textbook help its not in textbook solutions from the textbook C++ Programming 7th edition Malik,D.S Chapter 12 programming exercise 5 Banks offer various types of accounts, such as savings, checking, certificateof deposits, and money market, to attract customers as well as meet their specific needs. Two of the most commonly used accounts are savings andchecking. Each of these accounts has various options. For example, you mayhave a savings account that requires no minimum balance but has a lower interest rate....

  • Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’...

    Should be in C# Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this back can deposit (i.e. credit) money into their accounts and withdraw (i.e. debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction. Create base class Account and derived classes SavingsAccount and CheckingAccount that inherit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT