Need help getting my loan calculator to loop

I am having a lot of trouble getting my loan calculator to loop. My program is meant to prompt a user for some info, do some calculations, and create an amortization table telling the user how much they will have to pay each month in order to pay off their loan in the allotted time. My issue is that the program goes through successfully once, but just repeats itself with all the same info. More specifically, if the initial balance of the loan is 5000.00, and the new balance after a payment is 4500.00, instead of my program having a starting balance of 4500.00 the next month, it just starts at 5000.00 again. Can I get any help with this? Here is my code:
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main(){

	float Principal;
	float Interest;
	float Months;
	float AccInterest;
	float monPayment;
	float appPrincipal;
	float endBalance;
	
	cout << "Welcome to the loan calculator!" << endl;

	cout << "Please enter the amount of your loan: ";
		cin >> Principal;
	cout << "Please enter the interest rate: ";
		cin >> Interest;
	cout << "Finally, please enter the amount of months the loan is for: ";
		cin >> Months;

		

	
AccInterest = (Principal) * (Interest/100)/12;
monPayment = (Principal * (Interest/100)/12) * (pow(1+(Interest/100)/12, Months) / (pow(1+(Interest/100)/12, Months) -1));
appPrincipal = monPayment - AccInterest;
endBalance = Principal - monPayment + AccInterest;

	
	for(Months = 1; Months <=48; Months++){
	cout << Months << endl;
	cout << "Starting Principal: $" << Principal << endl;
	cout << "Payment is: $" << monPayment << endl;
	cout << "Accured interest is: $" << AccInterest << endl;
	cout << "Applied to Principal is: $" << appPrincipal << endl;
	cout << "End balance: $" << endBalance << endl;}







	return 0;}

it's a very difficult language.....
@GamerDJX

For one, the variables were never changed inside your loop, plus you have a loop that is set at 48, not how many months the user enters. Here is your program with the variables moved to inside the loop and the loop to user inputted months. You still have a problem with your loan payment amounts, etc. When a loan is paid in installments, it should be paid off at the end of the period. That formula is something you'll have to find out.

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
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

int main()
{

	float Principal;
	float Interest;
	int Months;
	float AccInterest;
	float monPayment;
	float appPrincipal;
	float endBalance;

	cout << "Welcome to the loan calculator!" << endl;

	cout << "Please enter the amount of your loan: ";
	cin >> Principal;
	cout << "Please enter the interest rate: ";
	cin >> Interest;
	cout << "Finally, please enter the amount of months the loan is for: ";
	cin >> Months;

	for(int x = 0; x < Months; x++) // No matter what user entered for months, You still had 48. Changed it. 
	{
		AccInterest = (Principal) * (Interest/100)/12;
		monPayment = (Principal * (Interest/100)/12) * (pow(1+(Interest/100)/12, Months) / (pow(1+(Interest/100)/12, Months) -1));
		appPrincipal = monPayment - AccInterest;
		endBalance = Principal - monPayment + AccInterest;
		cout << "Month " << x+1 << " of " << Months << endl;
		cout << "Starting Principal: $" << Principal << endl;
		cout << "Payment is: $" << monPayment << endl;
		cout << "Accured interest is: $" << AccInterest << endl;
		cout << "Applied to Principal is: $" << appPrincipal << endl;
		cout << "End balance: $" << endBalance << endl;
		Principal -= appPrincipal;
	}

	return 0;
}
Topic archived. No new replies allowed.