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

Write a program that calculates the balance of a savings account at the end of a

ID: 3641853 • Letter: W

Question

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. A loop should then iterate once for every month in the period, performing the followings:
A. Ask the user for the total amount deposited into the accoutn during tha tmonth. Do not accept negative numbers. This amount should be added to the balance.
B. Ask the user for the total amount withdrawn from the account during that month. Do not accept negative numbers or numbers greater than the balance after the deposits for the month have been added in.
After the last iteration, the program should display the following information:
- Starting balance at the beginning of the three-month period.
- Total deposits/withdrawals made during the three months.
- Final balance.

Explanation / Answer

#include <iostream>
using namespace std;

int main()
{
    double balance, stBalance;
    double int_rate;
    double TotalDep = 0.0; // total deposit made
    double TotalWithd = 0.0; // total withdrawal made
    cout << "Enter the starting balance: ";
    cin >> stBalance;
    balance = stBalance;
    cout << "Enter the annual interest rate in % (e.g. 20): " ;
    cin >> int_rate;
    int_rate = int_rate / 100.0;
    for (int i = 0; i < 3; i++) // main loop, iterating 3 times (once for each month)
    {
        balance += balance * (int_rate / 12.0) ;
        double dep = -1;
        do
        {
            cout << "Enter the amount of money, deposited during " << i+1 ;
            if (i == 0) cout << "st"; else if (i == 1) cout << "nd"; else cout << "rd";
            cout << " month: ";
            cin >> dep;
        } while (dep < 0);
        balance += dep;
        TotalDep += dep;
        double withd = -1;
        do
        {
            cout << "Enter the amount of money, withdrawn during " << i+1 ;
            if (i == 0) cout << "st"; else if (i == 1) cout << "nd"; else cout << "rd";
            cout << " month: ";
            cin >> withd;
        } while (withd < 0 || withd > balance);
        balance -= withd;
        TotalWithd += withd;
    }
    cout << "So, starting balance at the beginning of the 3 month period was " << stBalance << ' ' ;
    cout << "Total deposit made during 3 months = " << TotalDep << ' ' ;
    cout << "Total withdrawal made during 3 months = " << TotalWithd << ' ';
    cout << "FINAL balance = " << balance << ' ' ;
    system("pause");
}

I hope this gets you started. There are a number of ways to complete this!

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