Help with compound interest calculator

Hi all:

Still a beginner here and doing homework but have a issue with my program that I can figure out.

it runs correctly for low number of years 10 or so works but when I type in say a 30 year loan the final values and loan payments & interest grows doubling costs of loan and not sure where I went wrong... All of my inputs variables are "double" and asking for some set interest rate from user that increments by .125% to tell them what a monthly payment and total payments would be for a loan from 3% to 6% or 5% to (+3points)

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 cin.ignore();
		cin.clear();													//clear out the User Inputs in case junk left over.

		cout << HEADER1 << endl;										// these lines display all the information the user needs to know for the 1st test 
		cout << '\n';

		cout << " Please type your LOAN amount in dollars and cents without the dollar sign example 125000.00 ";
		cout << '\n';
		cin >> LOAN;


		cout << " Please type in the number of years of the loan, example 10 for 10 years. ";
		cout << '\n';
		cin >> YEARS;
		
		cout << " Please type the starting value interest rate we will give you total costs based off of an increasing span of 3% in 1/8% increments. ";
		cout << " Example type in a 5 for 5% or a 4.5 for 4.5%, then the program returns costs with a increments of 0.125% totaling costs over life of loan. ";
		cout << '\n';

		cin >> INT_YR;

		cout << COL_HED1 << endl;										// this display all the column headers
		cout << '\n';		
		BAL1 = LOAN;													//  Setting equal for dual ability same inputs.
		INT_DONE = ( INT_YR + 3 ) ;
		INT_YR = (INT_YR - 0.125);


		while (INT_YR < INT_DONE)										// External loop that increments the interest by 1/8%  
		{
			
			INT_YR = (INT_YR + 0.125);
			PAYMENT = (LOAN *(INT_YR/100)) / ((12 * (1- pow((1/1+INT_YR/1200),(-12*YEARS))))) ;



				while (BAL1 > PRINCIPAL)								// INTERNAL Loop below and the formulas that find for the payment and the final costs

				{
					NU_MO++;
					INT_MO = ((INT_YR / 12) / 100);
					INT_PD = (BAL1 * INT_MO);
					PRINCIPAL = (PAYMENT - INT_PD);
					BAL2 = (BAL1 - PRINCIPAL);
					HOW_MUCH = (INT_PD2 + INT_PD);

					if (BAL2 > PAYMENT)
					{
						BAL1 = BAL2;
					}
					else (BAL1 = PRINCIPAL);

					INT_PD2 = HOW_MUCH;
					FINALPMT = BAL2;
				}

			NU_MO++;														// Loop and Formulas for output to screen.
			INT_PD = (FINALPMT * INT_MO);
			FINALCOST = (FINALPMT + INT_PD);				
			BAL2 = (BAL1 - PRINCIPAL);
			HOW_MUCH = (INT_PD2 + INT_PD);

			TOTAL_INT = HOW_MUCH;
			TOTAL_COST = (PAYMENT * 12 * YEARS);
			cout << setprecision(3)  << setw(6) << INT_YR << "% " << setw(16) << fixed << setw(16) << setprecision(2) << " $" << PAYMENT << setw(16) << " $" << TOTAL_COST << endl;  // loop output to screen



		}
		
		cin.ignore();
		cin.clear();													//clear out the User Inputs in case junk left over.



		goto PROGRAM_BEGIN;		



It DOES work for low year counts and best I can tell using calculator does so per books values but once you step up in year count something happens and guessing it is in the calculation rounding or???

spent days on this and no farther ahead. And for some reason preview is not working so sorry if I end up editing this some..

thanks in advance.

M
My first impression is that you should not be using goto in a program. It is really never necessary. Perhaps that is somehow affecting the result of the program? Try taking out the goto statement and see if that works.
Hey bro,type in the whole program so tht we can check the code for flaws.
Use on bottom right. 😃
Topic archived. No new replies allowed.