60 699
Assignments Done
97,8%
Successfully Done
In April 2018

Answer to Question #5834 in C++ for haruna

Question #5834
write a program that calculates the balance of a savings account at the end of a 3 month period. it should ask the user for the starting balance and annual interest rate. a loop should then iterate once for every month in the period, performing the following:
(a)ask the user for the total amount deposited into the account during that month. do not accept negative no. this amount should be added to the balance.
(b)ask the user for the total amount withdrawn from the account during the month.do not accept negative numbers or number greater than the balance after the deposit for the month have been added in.

after the last iteration the program should a final report that includes the following
-starting balance at the beginning of the 3 month period
-total deposit made during the 3 month
-total withdrawal made during the 3 month
-final balance
Expert's 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 << '\n' ;
cout << "Total deposit made during 3 months = " << TotalDep << '\n' ;
cout << "Total withdrawal made during 3 months = " << TotalWithd << '\n';
cout << "FINAL balance = " << balance << '\n' ;
system("pause");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions