1. ## Any Better ideas???

This is my third program was just wondering if anybody had any better ideas???? seems to work for now...... was just wondering hmm

Code:
```#include <iostream>

using namespace std;

int main() /*function main*/
{

float bal = 0;
int month = 0;
float dep = 0;
float wit = 0;
float interest = 0;
float rate = 0;
float totalinterest =0;
float mi = 0;
float twit =0;
float tdep = 0;

cin >> bal;

cin >> rate;

cout <<"How many months has the account been opened?  :";
cin >> month;

rate = rate/12;

while (month >= 1)////start loop
{
cout <<"Please enter total deposits per month  \$: ";
cin >> dep;

if (dep < 0)
{	cout << "Error start over";
break;
}

cout <<"Please enter total withdrawals per month  \$: ";
cin >> wit;
if (wit < 0)
{	cout << "Error start over";
break;
}
twit += wit;
tdep += dep;
bal += dep;
bal -= wit;
mi = (rate/100) * bal;
totalinterest += mi;
bal += mi;
month--;

if (bal < 0)
{	cout <<" Account Closed see the Bank Manager";
break;
}
}

cout.setf(ios::showpoint);
cout.setf(ios::fixed);
cout.precision(2);

cout <<'\n';
cout << "The balance is " << bal << endl; //print output
cout << "The total deposits are: " << tdep << endl;
cout << "The total withdrawals are: " << twit << endl;
cout << "The total interest earned is : " << totalinterest << endl;
return 0;
}```

thanks for any input

2. rate = rate/12;
Consider using the following.

Code:
`rate /= 12;`
That's the only thing I see, though I did do just a quick read-through. Also check out your colon on the 3rd outpot statement.

3. Even though this is a very trivial program, and the code simple enough to follow with ease, you should get into the habit of commenting your code. If you don't do now, it will hunt you later...

4. Ditto. Up until very recently, I never commented, because I was sure I did need it, and no one else would read my code. Well... you run into problems with both of those ideas.

5. > and the code simple enough to follow with ease
Not that easy - the indentation is horrible.

float mi = 0;
float twit =0;
float tdep = 0;
How about using actual words rather than random abbreviations, because twit means something completely different.

Say
float monthly_interest;
float total_withdrawn;
float total_deposits;

> int main() /*function main*/
You have only 3 comments, and all state the obvious to anyone who is at all familiar with the language. As such, they're just useless clutter.
Sometimes tutors insist on them in the belief that it tells them if you understand the language.

For me, I'd put all the totals etc into a class called account, with a couple of functions to say
- update with dep and wit
- print the stats