running total help

Having alot of trouble with part C of my project. It says Calculate montly interest. monthly int is annual int div by 12. Then Multiply monthly int by balance.
I have to keep a running total of what ever number of months the user enters. I know how to do a simple running total but I dont know how to incorporate it here.
Also I keep getting a very low balance after putting in my info. Any constructive info is appreciated.

// This program calculates the balance of a savings account at the
// end of a period of time. It should ask the user for the annual interest
// rate, the starting balance, and the number of months since the account was
// opened. A loop should iterate once every month.
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double aInterest, sBalance,total; // starting balance and annual interest rate
double depositAmount, withDraw;
double mInterest, balance;
int acctAge;

// Output formatting
cout << fixed << showpoint << setprecision(2);

// Ask user to enter annual interest rate.
cout << "Enter your annual Interest rate?\n";
cin >> aInterest;

// Calculate monthly interest
mInterest = (aInterest / 12);

// Ask the user to enter their starting balance.
cout << "What is your starting balance?\n";
cin >> sBalance;

// Ask the user how many months since acct was est.
cout << "How many months have you had this account?\n";
cin >> acctAge;

// Amount despoited during the month
cout << "How much did you deposit this month?\n";
cin >> depositAmount;

while (depositAmount < 0)
{
cout << "You can not enter anything less than zero!\n";
cin >> depositAmount;
}
total = (sBalance += depositAmount);
// Display total thus far
cout << "Your total is " << total << endl;

// Amount withdrawn during the month
cout << "How much have you withdrawn this month?\n";
cin >> withDraw;
while (withDraw < 0)
{
cout << "Enter a number greater than zero.\n";
cin >> withDraw;
}
total = (sBalance -= withDraw);
// Display total thus far
cout << "Your total after deductions is " << total << endl;

// Get balance
balance = ( total * mInterest);

// Display balance
cout << "Your balance is " << balance << endl;
return 0;
}







balance = ( total * mInterest);

At this point in your code, total is the amount in the account. Surely that's the same thing as the balance? What is this calculation for?
after multiplying monthly int rate by balance (which i have named total) i have to add the result to balance (which is called balance).

is this right to get the months to loop:

for (variable = 1; variable <= acctAge; variable++)
after multiplying monthly int rate by balance (which i have named total) i have to add the result to balance (which is called balance).


You're not doing that, though. You never add anything to balance.
I finally got it Mos and thanks for your help. The biggest problem im having with programming is starting and organization. With more complicated programs im not sure what variables to use sometimes or where they would be best used in the program. Sounds funny but thats my biggest issue right now. I read my textbook and understand everything that it is saying but as soon as im given a "program challenge" I have trouble applying what I just learned to writing the program.
Topic archived. No new replies allowed.