Question: This code needs to be in C++ language and needs to compile as well please. Everything is explained below Q2. Class Design. [35 points] a.
This code needs to be in C++ language and needs to compile as well please. Everything is explained below
Q2. Class Design. [35 points] a. Design a class named Account that contains: A double data field named balance, which holds the account balance. A double data field named interestRate, which stores the annual interest rate. A no-arg constructor that creates an account with balance 0 and interestRate 0 get (accessor) and set (mutator) functions for balance and interestRate: o void setBalance (double balance); o double getBalance (); - Functions withdraw and deposit that add/subtract a specified amount to/from the account balance o void withdraw (double amount); o void deposit (double amount); A function that returns the projected balance after a given number of months, based on the current balance and interest rate: o double getFutureBalance (int months) *Make your data fields private and all other functions and constructors public. b. Separate the class declaration and implementation into Account.h and Account.cpp. You can use #ifndef/ # define / #endif to prevent multiple class declarations c. Write C++ code for testing the Account class. Your filename should be named testAccount.cpp Your code should create at least two different accounts, set various balance and interest rates, test depositing to/withdrawing from accounts, check balances remaining, and also get the future balance on both accounts d. Add a counter in your class implementation int Account: :numAccounts =0; Modify your no-arg constructor such that the numAccounts variable is incremented each time a new account is created. Implement a destructor so that each time an account is deleted numAccounts is decremented. Implement a getNumberofAccounts function that does not take any inputs but returns an int representing the number of accounts. Add test code in testAccount.cpp to print out number of accounts after creating/deleting accounts Files to submit: Account.cpp, Account.h, testAccount.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
