I'm trying to do this chart in c++ and i'm stuck.
Principle= 150,000.00 rate= 6% 0.005
Payment= 6,648.10 Years= 2 24
Month Principle interest $ to Prin Prin Balance
1 $150,000.00 $750.00 $5,898.10 $144,101.90
2 $144,101.90 $720.51 $5,927.59 $138,174.31
3 $138,174.31 $690.87 $5,957.23 $132,217.08
4 $132,217.08 $661.09 $5,987.01 $126,230.07
5 $126,230.07 $631.15 $6,016.95 $120,213.12
6 $120,213.12 $601.07 $6,047.03 $114,166.08
7 $114,166.08 $570.83 $6,077.27 $108,088.81
8 $108,088.81 $540.44 $6,107.66 $101,981.16
9 $101,981.16 $509.91 $6,138.19 $95,842.96
10 $95,842.96 $479.21 $6,168.89 $89,674.08
11 $89,674.08 $448.37 $6,199.73 $83,474.35
12 $83,474.35 $417.37 $6,230.73 $77,243.62
13 $77,243.62 $386.22 $6,261.88 $70,981.74
14 $70,981.74 $354.91 $6,293.19 $64,688.55
15 $64,688.55 $323.44 $6,324.66 $58,363.89
16 $58,363.89 $291.82 $6,356.28 $52,007.61
17 $52,007.61 $260.04 $6,388.06 $45,619.55
18 $45,619.55 $228.10 $6,420.00 $39,199.54
19 $39,199.54 $196.00 $6,452.10 $32,747.44
20 $32,747.44 $163.74 $6,484.36 $26,263.08
21 $26,263.08 $131.32 $6,516.78 $19,746.29
22 $19,746.29 $98.73 $6,549.37 $13,196.93
23 $13,196.93 $65.98 $6,582.12 $6,614.81
24 $6,614.81 $33.07 $6,615.03 ($0.22)
Here's my code , can anyone help?
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
|
#include "stdafx.h"
#include <stdio.h>
int main(void)
{
double principleA[24];
double interestA[24];
double dolPrinA[24];
double prinBalanceA[24];
int years, months, index;
double principle, rate, interest, dolPrin, princBalance, payment;
printf("Hello, this program calculates a payment plan for your loan and display every month's information.\n");
printf("Ok, to start we will need to ask you a few questions. Lets get started!\n");
principle= 150000;
years=2;
months= years * 12;
rate=6;
principleA[1] = principle;
interestA[1] = (rate/100)/12*principleA[1];
payment = 6648.10;//principleA[0] + interestA[0] / months;
dolPrinA[1] = payment - interestA[1];
prinBalanceA[1] = principleA[1] - dolPrinA[1];
printf("Month Principle interest $to princ Prin Balance\n");
for (index = 0; index < months;)
{
printf(" %2d %.2lf %.2lf %.2lf %.2lf\n", index++, principleA[1],interestA[1],dolPrinA[1],prinBalanceA[1]);
principleA[1]= prinBalanceA[index];
interestA[1] = (rate/100)/12*principleA[index];
dolPrinA[1]= payment - interestA[index];
prinBalanceA[1]=principleA[index] - dolPrinA[index];
principleA[2]=prinBalanceA[index];
interestA[2] = (rate/100)/12*principleA[index];
dolPrinA[2]= payment - interestA[index];
prinBalanceA[2]=principleA[index] - dolPrinA[index];
principleA[3]=prinBalanceA[index];
interestA[3] = (rate/100)/12*principleA[index];
dolPrinA[3]= payment - interestA[index];
prinBalanceA[3]=principleA[index] - dolPrinA[index];
principleA[4]=prinBalanceA[index];
interestA[4] = (rate/100)/12*principleA[index];
dolPrinA[4]=payment - interestA[index];
prinBalanceA[4]=principleA[index] - dolPrinA[index];
principleA[5]=prinBalanceA[index];
interestA[5] = (rate/100)/12*principleA[index];
dolPrinA[5]=payment - interestA[index];
prinBalanceA[5]=principleA[index] - dolPrinA[index];
}
return 0;
}
|