Question
1 A SSIGNMENT 4 M ORTGAGE A MORTIZATION T ABLE W ITH C OMMA S EPARATED CURRENCY FORMAT This assignment is to use your existing
1
ASSIGNMENT 4 MORTGAGE AMORTIZATION TABLE WITH COMMA SEPARATED CURRENCY FORMAT
This assignment is to use your existing program of assignment 2 to include additional number formatting functions to format your report in the output file using comma separated currency numbers. Your Input Data Set for the test run is as follows:
Your submission should follow the format as shown in the following submission example (partial codes are provided here):
// Author: John Doe
// CIS 3100 BMWA Spring 2018
// Assignment 4
#include
#include
#include
#include
using namespace std;
int length(double n)
{
if (n >= 10)
{
int d = log10(n);
return d + d / 3 + 4;
}
else
return 4;
}
void commaNumber(ofstream& o, double x)
{
int n, f; // n is integer part and f is the fraction
x = round(x * 100) / 100;
Your code is here..
}
2
void blanks(ofstream& o, int n)
{
for (int i = 1; i
o
}
void printAccountNumber(ofstream& o, double x, int s, int c) // x is the number, s is the total number of spaces, c is position - 1 for left, 2 for centerm 3 for right-justified
{
int b = s - length(x);
int h = b / 2;
switch (c)
{
case 1:
commaNumber(o, x);
blanks(o, b);
break;
case 2:
blanks(o, h);
commaNumber, (o, x);
blanks(o, b - h);
break;
case 3:
blanks(o, b);
commaNumber(o, x);
break;
default:
cout
break;
}
}
int main()
{
const int SPACE = 12;
double loanAmount, intRate, addtlPrincipal;
int years;
.Your code is here ..
string fileName;
cout
cin >> fileName;
ofstream outFile(fileName);
double monIntRate = intRate / 1200;
double mthlyPymt = loanAmount*monIntRate / (1 - 1 / pow(1 + monIntRate, years * 12));
double actPymt = mthlyPymt + addtlPrincipal;
double balance = loanAmount;
double interest;
double principal;
3
outFile
outFile
outFile
printAccountNumber(outFile, loanAmount, SPACE, 3);
outFile
outFile
outFile
outFile
printAccountNumber(outFile, mthlyPymt, SPACE, 3);
outFile
outFile
printAccountNumber(outFile, addtlPrincipal, SPACE, 3);
outFile
outFile
printAccountNumber(outFile, actPymt, SPACE, 3);
outFile
outFile
blanks(outFile, SPACE - 9);
outFile
blanks(outFile, SPACE - 8);
outFile
blanks(outFile, SPACE - 7);
outFile
. Your code is here
outFile.close();
system("pause");
return 0;
}
4
MORTGAGE AMORTIZATION TABLE
Amount: $ 298,000.00
Interest Rate: 4.625%
Term(Years): 10
Monthly Payment: $ 3,106.40
Additonal Principal: $ 709.64
Actual Payment: $ 3,816.05
Principal Interest Balance
1 $ 2,667.51 $ 1,148.53 $ 295,332.47
2 2,677.80 1,138.25 292,654.67
3 2,688.11 1,127.94 289,966.55
4 2,698.48 1,117.57 287,268.07
5 2,708.88 1,107.18 284,559.19
6 2,719.32 1,096.74 281,839.86
7 2,729.80 1,086.25 279,110.05
8 2,740.32 1,075.74 276,369.73
9 2,750.88 1,065.18 273,618.84
10 2,761.48 1,054.56 270,857.35
11 2,772.13 1,043.93 268,085.22
12 2,782.82 1,033.25 265,302.40
13 2,793.53 1,022.51 262,508.86
14 2,804.30 1,011.75 259,704.55
15 2,815.11 1,000.94 256,889.44
16 2,825.96 990.09 254,063.47
17 2,836.86 979.20 251,226.60
18 2,847.78 968.26 248,378.82
19 2,858.76 957.28 245,520.04
20 2,869.78 946.27 242,650.26
21 2,880.84 935.21 239,769.42
22 2,891.94 924.11 236,877.47
5
23 2,903.09 912.97 233,974.36
24 2,914.28 901.77 231,060.07
25 2,925.51 890.53 228,134.57
26 2,936.78 879.26 225,197.76
27 2,948.11 867.95 222,249.66
28 2,959.46 856.59 219,290.17
29 2,970.88 845.17 216,319.29
30 2,982.32 833.73 213,336.97
31 2,993.82 822.24 210,343.14
32 3,005.36 810.70 207,337.77
33 3,016.94 799.11 204,320.82
34 3,028.57 787.49 201,292.26
35 3,040.25 775.80 198,252.01
36 3,051.96 764.10 195,200.04
37 3,063.73 752.33 192,136.30
38 3,075.53 740.52 189,060.77
39 3,087.38 728.66 185,973.39
40 3,099.28 716.76 182,874.10
41 3,111.23 704.83 179,762.85
42 3,123.23 692.84 176,639.64
43 3,135.26 680.79 173,504.36
44 3,147.34 668.71 170,357.02
45 3,159.48 656.58 167,197.54
46 3,171.65 644.40 164,025.89
47 3,183.88 632.17 160,842.01
48 3,196.15 619.90 157,645.85
49 3,208.46 607.59 154,437.39
50 3,220.82 595.23 151,216.55
51 3,233.25 582.80 147,983.30
52 3,245.71 570.35 144,737.60
53 3,258.21 557.84 141,479.38
54 3,270.78 545.28 138,208.60
6
55 3,283.38 532.67 134,925.22
56 3,296.03 520.01 131,629.17
57 3,308.73 507.31 128,320.44
58 3,321.48 494.56 124,998.94
59 3,334.30 481.76 121,664.64
60 3,347.15 468.92 118,317.50
61 3,360.05 456.01 114,957.46
62 3,373.00 443.06 111,584.46
63 3,386.00 430.06 108,198.47
64 3,399.05 417.00 104,799.41
65 3,412.15 403.91 101,387.27
66 3,425.30 390.75 97,961.97
67 3,438.50 377.56 94,523.47
68 3,451.75 364.31 91,071.72
69 3,465.05 351.00 87,606.66
70 3,478.40 337.64 84,128.25
71 3,491.82 324.24 80,636.42
72 3,505.28 310.79 77,131.16
73 3,518.78 297.27 73,612.36
74 3,532.34 283.70 70,080.02
75 3,545.96 270.10 66,534.05
76 3,559.63 256.43 62,974.43
77 3,573.34 242.71 59,401.08
78 3,587.11 228.93 55,813.95
79 3,600.94 215.12 52,213.01
80 3,614.82 201.24 48,598.19
81 3,628.76 187.31 44,969.44
82 3,642.73 173.31 41,326.69
83 3,656.78 159.28 37,669.91
84 3,670.88 145.18 33,999.04
85 3,685.01 131.03 30,314.00
86 3,699.23 116.84 26,614.77
7
87 3,713.48 102.57 22,901.29
88 3,727.80 88.26 19,173.50
89 3,742.15 73.90 15,431.34
90 3,756.59 59.46 11,674.75
91 3,771.07 45.00 7,903.68
92 3,785.59 30.46 4,118.09
93 3,800.19 15.86 317.89
94 317.89 1.23 0.00
This assignment is to use your existing program of assignment 2 to include additional number formatting functions to format your report in the output file using comma separated currency numbers. Your Input Data Set for the test run is as follows: CWindowslsystem32\cmd.exe Enter Loan amount G-9999999>. for example 300000.90 500600 Enter annual interest rate(0-50), for example 4.25 mean ing 4.25%: 4.125 Enter no. of years as integex 1-50for example 30: 15 Enter additional principal per month (0-9999999>. for example 300: 800 Send the mortgage amortization table to a fileStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started