Question
Bank Account Define a class named BankAccount with member variables to store the following: balance : a double number of withdrawals : an int number
Bank Account
Define a class named BankAccount with member variables to store the following:
balance: a double
number of withdrawals: an int
number of deposits: an int
The class should have the following member functions:
A default constructor that sets the balance to 0.0
A constructor that accepts the initial balance as an argument
deposit: a function to add a value to the balance and adds to the number of deposits; make sure to test if the amount to be deposited is greater than 0.
withdraw: a function to subtract a value from the balance and adds to the number of withdrawals; do not allow overdraft.
printStatement: a function to print the balance, the number of withdrawals and the number of deposits made.
In the same .cpp file define a main function to test your class. It should create an account with an amount specified by the user and then enter a loop to allow the user to enter several withdrawals and deposits. When done, a statement that includes the balance, number of withdrawals and number of deposits should be printed.
Turn in the .cpp file with the class implementation and main.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started