#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
int numMonths;
double balance;
double numBalance;
float rate;
double totDeposited = 0.0 ;
double totWithdrawn = 0.0 ;
double mthlyInterRate = 0.0;
double totInterest = 0.0;
cout << " Enter the initial balance ===> ";
cin >> balance;
cout << " Enter the number of months to cover: ===> ";
cin >> numMonths;
cout << " Enter the annual interest rate (decimal format; e.g., 5 not .05) ===> ";
cin >> rate;
for (int month = 1; month <= numMonths; month++)
{ double deposited, withdrawn;
cout << " Enter the amount deposited for month ===> " << month <<":" ;
cin >> deposited;
cout << " Enter the amount withdrawn for month ===> "<< month <<":" ;
cin >> withdrawn;
mthlyInterRate = (rate/100)/12;
totDeposited += deposited ;
totWithdrawn += withdrawn ;
numBalance = balance + deposited - withdrawn;
mthlyInterRate = numBalance *mthlyInterRate;
totInterest += mthlyInterRate;
numBalance += mthlyInterRate;
}
cout << " Starting balance: $ " << balance << endl;
cout << " Total amount deposited: $ " << totDeposited << endl;
cout << " Total amount withdrawn: $ " << totWithdrawn << endl;
cout << " Total interest earned: $ " << totInterest << endl;
cout << " Final Balance: $" << numBalance << endl;
return 0;
}
this is how it suppose to come out plzzz help me
Enter the initial balance ===> 1000
Enter the number of months to cover: ===> 3
Enter the annual interest rate (decimal format; e.g., 5 not .05) ===> 10
Enter the amount deposited for month 1 ===> 500
Enter the amount withdrawn for month 1 ===> 400
Enter the amount deposited for month 2 ===> 600
Enter the amount withdrawn for month 2 ===> 700
Enter the amount deposited for month 3 ===> 800
Enter the amount withdrawn for month 3 ===> 900
Starting balance: $ 1000.00
Total amount deposited: $ 1900.00
Total amount withdrawn: $ 2000.00
Total interest earned: $ 25.64
Final balance: $ 925.64