Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

10.7 (SavingsAccount Class) Create a SavingsAccount class. Use a static data mem

ID: 3639062 • Letter: 1

Question

10.7 (SavingsAccount Class) Create a SavingsAccount class. Use a static data member
annualInterestRate to store the annual interest rate for each of the savers. Each member of the
class contains a private data member savingsBalance indicating the amount the saver currently
has on deposit. Provide member function calculateMonthlyInterest that calculates the monthly
interest by multiplying the balance by annualInterestRate divided by 12; this interest should be
added to savingsBalance. Provide a static member function modifyInterestRate that sets the
static annualInterestRate to a new value. Write a driver program to test class SavingsAccount.
Instantiate two different objects of class SavingsAccount, saver1 and saver2, with balances of
$2000.00 and $3000.00, respectively. Set the annualInterestRate to 3 percent. Then calculate
the monthly interest
and print the new balances for each of the savers. Then set the annualInterestRate to 4 percent,
calculate the next month’s interest and print the new balances for each of the savers. Note you
should specify const (constant) objects and const member functions appropriately in your class.
Sample of Execution:
Initial balances:
Saver 1: $2000.00 Saver 2: $3000.00
Balances after 1 month's interest applied at .03:
Saver 1: $2005.00 Saver 2: $3007.50
Balances after 1 month's interest applied at .04:
Saver 1: $2011.68 Saver 2: $3017.53

Explanation / Answer

#include using namespace std; class SavingsAccount { public: SavingsAccount(){} SavingsAccount(int value); ~SavingsAccount(){} static float annualInterestRate; void calculateMonthlyInterest(); static void modifyIntererestRate(float value); float GetBalance() const { return savingsBalance; } private: float savingsBalance; }; SavingsAccount::SavingsAccount(int value) { savingsBalance = value; } float SavingsAccount::annualInterestRate = 0; void SavingsAccount::calculateMonthlyInterest() { savingsBalance += ((savingsBalance * annualInterestRate) / 12); } void SavingsAccount::modifyIntererestRate(float value) { annualInterestRate = value; } int main() { SavingsAccount saver1(2000.00); SavingsAccount saver2(3000.00); SavingsAccount::modifyIntererestRate(3); saver1.calculateMonthlyInterest(); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote