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

Create a SavingsAccount class. Use a static data member to contain the annualInt

ID: 3547235 • Letter: C

Question

Create a SavingsAccount class. Use a static data member to contain

the annualInterestRate for each of the savers. Each member of the class

should contain a private data member savingsBalance indicating the amount

the saver currently has on deposit. Provide a calculateMonthlyInterest

member function 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 savingsAccount objects,

saver1 and saver2, with balances of $2000.00 and $3000.00, respectively. Set

annualInterestRate to 3%, then calculate the interest earned over the first

month and print the new balances for each of the savers after earning that

interest. Then, set the annualInterestRate to 4% for the second month.

Calculate the second month

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: // Each member of the class contains a private data member // savingsBalance indicating the amount the saver currently has // on deposit. float savingsBalance; }; // copy constructor to initialize the value at instantiation SavingsAccount::SavingsAccount(int value) { savingsBalance = value; } // Use a static data member annualInterestRate to store the annual interest // rate for each of the savers. float SavingsAccount::annualInterestRate = 0; // Provide member function calculateMonthlyInterest that calculates the // monthly interest by multiplying the savingsBalance by annualInterestRate // divided by 12 and then adds this interest to savingsBalance. void SavingsAccount::calculateMonthlyInterest() { savingsBalance += ((savingsBalance * annualInterestRate) / 12); } //Provide a static member function modifyIntererestRate that sets the // static annualInterestRate to a new value. void SavingsAccount::modifyIntererestRate(float value) { annualInterestRate = value; } int main() { // Instantiate two different objects of class SavingsAccount, saver1 // and saver2, with balances of $2000.00 and $3000.00, respectively. SavingsAccount saver1(2000.00); SavingsAccount saver2(3000.00); // Set the annualInterestRate to 3%. SavingsAccount::modifyIntererestRate(3); // Then calculate the monthly interest and print the new balances for // each of the savers. saver1.calculateMonthlyInterest(); cout