Loan and amortization table.. how!?

Please help me. I thought this would be easy and then I started and WOAH.. I don't know.. I think I'm just confusing myself more... He wants the following:

Print a welcome message.
Loop until the user wants to leave the program.
- an input section which asks for some information including amount of the loan, the number of payments (in terms of months), and the annual interest rate.
- Table: For example, given the amount of the loan is 10000, the annual interest rate is 8% and the number of payments is 12, a table similar to the following will be generated
1
2
3
4
5
6
Month     Paid Principal        Paid Interest     New Balance
1              803.22                66.67            9196.78
2              808.57	             61.31	      8388.21
3              813.96                55.92            7574.25
..             .......               ......             ......
12             864.12                 5.76              -0.00


etc you don't know how many months user will input...


-an output section to print out other results such as monthly interest rate, monthly payment, accumulated interest payment over the loan period, and total payment, along with the input parameters.

1
2
3
4
5
6
7
8
Customer:		John Doe
				loan amount: 		10000.00
		 		annual interest rate: 	 8.00%
		 		number of payments: 	 12
		 		monthly interest: 	  0.6667%		
		 		accumulated interest :    438.61
		 		monthly payment : 	 869.89
		 		total payment :		10438.61


So, I don't think the second table.. with customer name will be difficult but I got stuck after asking all the input.. I blanked out. How would I make it specific for each month?? I'm a beginner so please don't be mean.. I'm trying! :/ Heres what I have so far.. I might be completely wrong.. I haven't read up on the other loops and only know the while loop right now.. but if another loop is needed let me know so I can read up on it...


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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
********************************************************************/
#include <iostream>				//For input/output streams
#include <cmath>				//For math used in program
#include <iomanip>				//Output manipulator
#include <fstream>				//Used for output file
#include <string>				//Use with strings
using namespace std;

int main()
{	
	//Variable identifiers
	string firstName, lastName;		//User information
	int month;						//Month
	int payments;					//Number of payments
	char answer;					//Answer quit/start
	double loanAmount;				//Loan amount
	double anIntRate;				//Yealy interest Rate
	double monIntRate;				//Monthly interest rate
	double monthPayment;			//Monthly payment
	double balance;					//Balance due
	double monthPrinciple;			//Monthly principle paid
	double monthPaidInt;			//Month interest paid


	


		cout<<"                            River Bank                          "
		<<endl<<endl;
	cout<<"Hello and welcome to River Bank's electronic"
		<<" loan amortization calculator. Here we will"
		<<" make a table for you when given the amount"
		<<" of the loan, the interest rate, and the"
		<<" number of payments you wish to have."<<endl;

	
	while (true)
	{
		//Ask user if they want to start or quit
		cout<<"Want to start or do you want to quit?"
			<<" Enter 's' for start, or 'q' to quit."<<endl;
		cin>>answer;

		
		//If letter s is chosen
		if (answer == 's')
		{	cout<<"Okay.. we will first need some basic"
				<<" information about you and your loan.\n\n";
			
			//Ask user for first name
			cout<<"What is your first name?"<<endl;	
			cin>>firstName;
			//Ask user for last name
			cout<<"What is your last name?"<<endl;
			cin>>lastName;
			//Ask user for the loan amount
			cout<<"What is the full amount of your loan?"<<endl;
			cin>>loanAmount;
			//Ask user for the interest rate
			cout<<"What is the annual interest rate on your loan?"<<endl;
			cin>>anIntRate;
			//Ask user for the amount of payments
			cout<<"How many payments do you want to make"
				<<" to pay this loan off? Please answer"
				<<" me with the number of months."<<endl;
			cin>>payments;

			
				
				
			//Calculations
			//Monthly interest rate
			monIntRate = ((anIntRate/100)/12);
			//Monthly payment
			monthPayment = (loanAmount * monIntRate * (pow(1+monIntRate, payments)
				/(pow (1+monIntRate, payments)-1)));
			//Amount paid to interest each month
			monthPaidInt = balance * monIntRate;
			//Amount paid to principle
			monthPrinciple = monthPayment-monthPaidInt;
			//New balance due
			balance = balance - monthPrinciple;

			month=1;
			cout<<setw(4)<<right<<month<<setw(7)<<right<<monthPrinciple<<setw(7)<<right<<monthPaidInt<<setw(8)<<right<<balance;
				






			






			


			cout<<"Do you want to do this again? (y/n) => "; 
			cin>>answer;				//reuse the answer variable
				
			if (answer != 'y' && answer != 'Y')
			{
				//stop if the choice is not 'y' or 'Y'
				cout<<"Thank you for visiting River Bank's"
				<<" electronic loan amortization calculator"
				<<". Have a wonderful day and come visit us"
				<<" again soon for all your banking needs."<<endl; 
						break;	
			}

		
		//If user chooses to quit program
		else
			cout<<"Thank you for visiting River Bank's"
				<<" electronic loan amortization calculator"
				<<". Have a wonderful day and come visit us"
				<<" again soon for all your banking needs."<<endl;
	
	
		}

	return 0;



	}


}

FYI: When you get your doubles, you can't put in values like "8.00%", you will either have to divide by 100.0 yourself or tell them to input a value like 0.08.

I would probably just create a for loop (you can read up on that if you want), that increments until you get to the numbers of months they specified, calculating the interest/payments etc the way you are currently (although I haven't actually checked your formulas). You will probably need a variable like "temp_principal" that stores the new principal for calculation of interest etc.
Topic archived. No new replies allowed.