In c Write a program that calculates the balance of a saving

In c++ 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:
- starting balance at the beginning of the three-month period
-total deposits made during the three months
- total withdrawals made during the three months
- total interest posted to the account during the three months
- final balance

Solution

#include <iostream>
using namespace std;

int main()
{
double starting_Balance = 0, annual_interest_rate = 0, monthly_interest_rate = 0, total_amount_deposited = 0, withdrawn_amount = 0, current_month_interest = 0;
double starting_Balance_Array[4], end_Balance_Array[4];
  
cout << \"Please enter the starting balance: \";
cin >> starting_Balance;
cout << \"Please enter the annual Interest rate: \";
cin >> annual_interest_rate;

double total_balance = starting_Balance;
monthly_interest_rate = annual_interest_rate / 12;
int month = 0;

double total_amount_deposited_three_months = 0;
double total_amount_withdrawn_three_months = 0;
double total_interest_three_months = 0;
while(true)
{
month++;
if(month == 4) break;

cout << \"Please enter the amount deposited in month \" << month << \" : \";
cin >> total_amount_deposited;
while (total_amount_deposited < 0)
{
cout<< endl << \"Please enter positive amount\" << endl;
cout << \"Please enter the amount deposited in month \" << month << \" : \";
cin >> total_amount_deposited;
}
total_balance += total_amount_deposited;
starting_Balance_Array[month] = total_balance;

total_amount_deposited_three_months += total_amount_deposited;

cout << \"Please enter the amount withdrawn in month \"<< month << \" : \";
cin >> withdrawn_amount;
while (withdrawn_amount < 0 || withdrawn_amount > total_balance)
{
cout<< endl << \"Please enter positive amount and amount less than total Amount deposited\" << endl;
cout << \"Please enter the amount withdrawn in month \"<< month << \" : \";
cin >> withdrawn_amount;
}
total_amount_withdrawn_three_months += withdrawn_amount;
total_balance -= withdrawn_amount;
end_Balance_Array[month] = total_balance;
  
double monthly_Average_Balance = ((end_Balance_Array[month] + starting_Balance_Array[month])/2);
current_month_interest = monthly_Average_Balance* monthly_interest_rate;
total_balance += current_month_interest;

total_interest_three_months += current_month_interest;

}
  
cout << endl<< \"Starting balance at the beginning of the three-month period: \" << starting_Balance << endl;
cout << \"Total deposits made during the three months: \" << total_amount_deposited_three_months << endl;
cout << \"Total withdrawls made during the three months: \" << total_amount_withdrawn_three_months << endl;
cout << \"Total interest posted to the account during the three months: \" << total_interest_three_months << endl;
cout << \"Final balance: \" << total_balance << endl;

return 0;
}



/* output:

Please enter the starting balance: 100
Please enter the annual Interest rate: 5
Please enter the amount deposited in month 1 : 100
Please enter the amount withdrawn in month 1 : 50

Please enter the amount deposited in month 2 : 100
Please enter the amount withdrawn in month 2 : 50

Please enter the amount deposited in month 3 : 100
Please enter the amount withdrawn in month 3 : 50

Starting balance at the beginning of the three-month period: 100
Total deposits made during the three months: 300
Total withdrawls made during the three months: 150
Total interest posted to the account during the three months: 393.736
Final balance: 643.736

*/

In c++ 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
In c++ 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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site