Question
Enhance this Account class to compute the interest on the current balance. An account has initial balance of $10,000.00, and 6% percent annual interest is
Enhance this Account class to compute the interest on the current balance. An account has initial balance of $10,000.00, and 6% percent annual interest is compounded monthly until the investement is double. Write a main function to determine the number of months to double the initial investment. Create a menu to allow the user to enter the initial investement and the annual interest rate.
#include
class Account{ public: double amount; Account(double a){ amount = a; } void deposit(double a){ if(a < 0){ return; } amount += a; } void withdraw(double a){ if(amount-a < 0){ return; } amount -= a; } double get_balance(){ return amount; } };
int main() { Account my_account(100); // Set up my account with $100 my_account.deposit(50); my_account.withdraw(175); // Penalty of $20 will apply my_account.withdraw(25);
cout << "Account balance: " << my_account.get_balance() << " "; my_account.withdraw(my_account.get_balance()); // withdraw all cout << "Account balance: " << my_account.get_balance() << " "; return 0; }
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