For loop question

Hi everyone, I have a few simple questions that I am not figuring out. Below is code for a program that cins an amount from the user, asks for an interest rate, and calculates interest earned with a new balance each year for 10 years. I know the code is a mess right now but I am having a problem with the for loop. I can get it to display:

Year Balance
____ _______
1
2
3
4
5
6
7
8
9
10

How do I get the initial balance (input by the user) in the first year and then update each year? Assuming there is only one deposit and they earn x% each year.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <fstream>

using namespace std;

int main()
{
   int amount;
   double interest;
   double balance;
   double per; 
   cout << "What is the initial amount in the account?  ";
   cin >> amount;
   cout << "What is the interest rate?  ";
   cin >> interest;
  
   
        
   cout << "Year" << "\t\t" << "Balance" << endl;
   cout << "____" << "\t\t" << "_______" << endl;
   
   
   for (int i = 1; i <= 10; i++)
   {
       cout << i << "\t\t" << balance << endl; 
       
   }

system("pause");
return 0;
}        
hope this helps

#include <iostream>
// #include <fstream>

using namespace std;

int main()
{
// int amount;
double interest;
double balance;
// double per;
cout << "What is the initial amount in the account? ";
cin >> balance;
cout << "What is the interest rate? ";
cin >> interest;



cout << "Year" << "\t\t" << "Balance" << endl;
cout << "____" << "\t\t" << "_______" << endl;

for (int i = 1; i <= 10; i++)
{
balance += (interest/100)*balance;
cout << i << "\t\t" << balance << endl;

}

system("pause");
return 0;
}
Topic archived. No new replies allowed.