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

Use Looping write a C++ program using loops that calculates the balance of a sav

ID: 3771205 • Letter: U

Question

Use Looping write a C++ program using loops 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
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.

After the last iteration, the program should display a report that includes the following
information:
• starting balance at the beginning of the three-month period
• total deposits made during the three months
• total withdrawals made during the three months
• final balance

Explanation / Answer


#include <iostream.h>
#include <stdlib.h>
#include<conio.h>
void main()
{
clrscr();
int stbal=0,deposit=0,withdrawl=0,finalbal=0,totdp=0,totwd=0;
char dec;
cout<< "Please Enter Starting Balance: ";
cin>>stbal;
finalbal=stbal;
do
{
abc:
cout<< "Please Enter Deposit amount: ";
cin>>deposit;
if(deposit>=0)
{
   finalbal=finalbal+deposit;
   totdp=totdp+deposit;
}
   else
   { goto abc;}
xyz:
cout<< "Please Enter Withdrawl amount: ";
cin>>withdrawl;
if(withdrawl>=0&&withdrawl<=finalbal)
{
   finalbal=finalbal-withdrawl;
   totwd=totwd+withdrawl;
}
else
   { goto xyz;}
cout << " Do you want to continue for next month(Y/N):";
cin>>dec;
} while(dec=='y'|dec=='Y');
cout << " Start balance: "<<stbal;
cout << " Total Deposit: "<<totdp;
cout << " Total Withdrawl: "<<totwd;
cout << " Final balance: "<<finalbal;
getch();
}

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