Answer:
Check the explanation
Step-by-step explanation:
# 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;
}
Kindly check the output in the attached image below.