Project Deliverables include: * Header .h file * Class Definition .cpp file * Te
ID: 3623044 • Letter: P
Question
Project Deliverables include:* Header .h file
* Class Definition .cpp file
* Test .cpp file
* User documentation .docx file
* a Visio .vsd flowchart.
18.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 static member function modifyInterestRate that sets the static annualInterstRate to a new value. Write a driver program to test class SavingsAccount. Instantiate two different objects of class SavingsAccount, saver1 and saver2, with the 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 balance for each of the savers.
Explanation / Answer
please rate - thanks
#include <iostream>
#include <iomanip>
using namespace std;
class SavingsAccount
{public:
SavingsAccount( double bal )
{savingsBalance=bal;
}
void calculateMonthlyInterest();
static void modifyInterestRate(double);
void printBalance()const;
private:
double savingsBalance;
static double annualInterestRate;
};
double SavingsAccount::annualInterestRate =0;
void SavingsAccount::calculateMonthlyInterest()
{savingsBalance += savingsBalance*annualInterestRate/12.;
}
void SavingsAccount::modifyInterestRate(double interest )
{annualInterestRate=interest/100.;
}
void SavingsAccount::printBalance() const
{cout<<setprecision(2)<<fixed<<"$"<<savingsBalance;
}
int main()
{SavingsAccount a(2000.00);
SavingsAccount b(3000.00);
SavingsAccount::modifyInterestRate(3);
cout<<"Starting balance account a: ";
a.printBalance();
cout<<"Starting balance account b: ";
b.printBalance();
a.calculateMonthlyInterest();
b.calculateMonthlyInterest();
cout<<" monthly interest at 3%: account a ";
a.printBalance();
cout<<" account b ";
b.printBalance();
SavingsAccount::modifyInterestRate(4);
a.calculateMonthlyInterest();
b.calculateMonthlyInterest();
cout<<" monthly interest at 4%: account a ";
a.printBalance();
cout<<" account b ";
b.printBalance();
cout<<endl;
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.