Question

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 class should provide the following operations: set interest rate, retrieve interest rate, set minimum balance, retrieve minimum balance, set service charges, retrieve service charges, post interest, verify if the balance is less than the minimum balance, write a check, withdraw (override the method of the base class), and print account informa- tion. Add appropriate constructors.
0 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
Know the answer?
Add Answer to:
14 b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount...
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
  • 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...

  • 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...

  • 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...

  • 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...

  • TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static...

    TASK 1 Create a new class called CheckingAccount that extends BankAccount. It should contain a static constant FEE that represents the cost of clearing onecheck. Set it equal to 15 cents. Write a constructor that takes a name and an initial amount as parameters. Itshould call the constructor for the superclass. It should initializeaccountNumber to be the current value in accountNumber concatenatedwith -10 (All checking accounts at this bank are identified by the extension -10). There can be only one...

  • 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...

  • 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...

  • /*Design a class BankAccount that has the following properties: * Account Number (should be static and increased every...

    /*Design a class BankAccount that has the following properties: * Account Number (should be static and increased every time an account is created. * An array of holders max 5 and a holder is a Person object * A int to rember how many holders * Balance (float) * Date opened * interest rate * Constructors * addHolder will add one more Person as a holder, if you reach 5 don't add. * Setters getters * method payInterest that add...

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