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

Savings Account Balance Write a program that calculates the balance of a savings

ID: 3538587 • Letter: S

Question

Savings Account Balance
Write a program that calculates the balance of a savings account at the end of a three-
month period. It should ask the user for the starting balance and the annual interest
rate. A loop should then iterate once for every month in the period, performing the
following steps:
A) Ask the user for the total amount deposited into the account during that month
and add it to the balance. Do not accept negative numbers.
B) Ask the user for the total amount withdrawn from the account during that
month and subtract it from the balance. Do not accept negative numbers or
numbers greater than the balance after the deposits for the month have been
added in.
C) Calculate the interest for that month. The monthly interest rate is the annual
interest rate divided by 12. Multiply the monthly interest rate by the average of
that month%u2019s starting and ending balance to get the interest amount for the
month. This amount should be added to the balance. After the last iteration, the program should display a report that includes the following information:
%u2022 starting balance at the beginning of the three-month period
%u2022 total deposits made during the three months
%u2022 total withdrawals made during the three months
%u2022 total interest posted to the account during the three months
%u2022 final balance

Explanation / Answer

please rate - thanks

any questions just ask


# include <iostream>
#include<iomanip>
using namespace std;
int main ()
{double start,balance,rate,deposit=0,withdraw=0,amt,sum,totInterest=0,interest;
int i;
cout<<setprecision(2)<<fixed;
cout<<"Enter starting balance: ";
cin>>balance;
start=balance;
cout<<"Enter annual interest rate: ";
cin>>rate;
rate/=12.;
for(i=1;i<=3;i++)
   {cout<<"For month "<<i<<endl;
   sum=balance;
    cout<<"Enter total amount deposit: ";
    cin>>amt;
    while(amt<0)
        {cout<<"Must not be negative-retry ";
        cout<<"Enter total amount deposit: ";
        cin>>amt;
        }
    deposit+=amt;
    balance+=amt;
    cout<<"Enter total amount withdrawn: ";
    cin>>amt;
    while(amt<0||amt>balance)
        {cout<<"Must not be negative, or greater than balance ($"<<balance<<")-retry ";
        cout<<"Enter total amount withdrawn: ";
        cin>>amt;
        }
    withdraw+=amt;
    balance-=amt;
    interest=(sum+balance)/2.*rate;
    totInterest+=interest;
    balance+=interest;
}

cout<<"Starting balance at the beginning of the three month period: $"<<start<<endl;
cout<<"total deposits made during the three months: $"<<deposit<<endl;
cout<<"total withdrawals made during the three months: $"<<withdraw<<endl;
cout<<"total interest posted to the account during the three months $"<<totInterest<<endl;
cout<<"final balance: $"<<balance<<endl;
system("pause");
return 0;

}


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