Write a Savings Account class that stores a savings account\'s annual interest r
ID: 3624991 • Letter: W
Question
Write a Savings Account class that stores a savings account'sannual interest rate and balance The class constructor should accept
the amount of the savings account's starting balance. The class
should also have methods for subtracting the amount of a withdrawl,
adding the amount of a deposite, and adding the amount of monthly
interest to the balance. The monthly interest rate is the annual
interest rate divided by 12. To add the monthly interest to the balance,
multiply the monthly interest rate by the balance and add the result to
the balance
Explanation / Answer
Dear, Here is the code Haven't specified the language you are looking for giving you in c++ please come back Class:// Class Date definition
class SavingsAccount
{
public :
SavingsAccount(); // default constructor
// set the balance amount
void setSavingsBalance( double );
// returns the balance
double getSavingsBalance();
// calculates the monthly interest
void calculateMonthlyInterest();
// modifies the rate of interest
// static member function
static void modifyInterestRate( float );
// ~SavingsAccount(); // destructor
private :
static float annualInterestRate;
double savingsBalance;
}; // end class SavingsAccount Main code:
int main() // function main begins program execution
{
// instantiate two different objects of//type SavingsAccount
SavingsAccount account1, account 2;
// print the initial balances of the objects
cout << " Initially saver1's account has a balance of $ "
<< account 1.getSavingsBalance();
cout << " Initially saver2's account has a balance of $ "
<< account 2.getSavingsBalance();
// set the balances to be 2000 and 3000
account1.setSavingsBalance(2000.00);
account2.setSavingsBalance(3000.00);
// print the balances of the objects after setting//the balances
cout << " The saver1's account has a balance of $ "
<< account1.getSavingsBalance();
cout << " The saver2's account has a balance of $ "
<< account2.getSavingsBalance();
// modify the rate of interest to 3
account1.modifyInterestRate(3);
account2.modifyInterestRate(3);
// calculate the interest amounts
account1.calculateMonthlyInterest();
account2.calculateMonthlyInterest();
// print the balances after the interest was added
cout<<" The saver1's account after an annualInterestof 3% has a balance of $"<< account1.getSavingsBalance(); cout<<" The saver2's account after an annualInterest
of 3% has a balance of $"<< account2.getSavingsBalance();
// modify the rate of interest to 3
account1.modifyInterestRate(4);
account2.modifyInterestRate(4);
// calculate the interest amounts
account1.calculateMonthlyInterest();
account2.calculateMonthlyInterest();
// print the balances after the interest was added
cout<<" The saver1's account after an annualInterest of 4% has a balance of $"
<< account1.getSavingsBalance();
cout<<" The saver2's account after an annualInterest of 4% has a balance of $"
<< account2.getSavingsBalance();
return 0; // indicate program executed successfully
}Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.