Pure Programmer

Project: Amortization Table (Revisited)

In the AmortizationTable1 project we had a problem with accumulation error in our balance. We can avoid this problem by working with integers whenever possible. If we take value like the payment or balance that is represented in dollars and cents then multiply it by 100, we can convert a decimal value to an integer value. Re-write the Amortization Table project to use long integers for the payment, interest, principle and balance.

Output
\$ g++ -std=c++17 AmortizationTable2.cpp -o AmortizationTable2 -lfmt \$ ./AmortizationTable2 10000 0.05 2 Month Payment Principle Interest Balance 0 10000.00 1 438.71 397.04 41.67 9602.96 2 438.71 398.70 40.01 9204.26 3 438.71 400.36 38.35 8803.90 4 438.71 402.03 36.68 8401.87 5 438.71 403.70 35.01 7998.17 6 438.71 405.38 33.33 7592.79 7 438.71 407.07 31.64 7185.72 8 438.71 408.77 29.94 6776.95 9 438.71 410.47 28.24 6366.48 10 438.71 412.18 26.53 5954.30 11 438.71 413.90 24.81 5540.40 12 438.71 415.62 23.09 5124.78 13 438.71 417.36 21.35 4707.42 14 438.71 419.10 19.61 4288.32 15 438.71 420.84 17.87 3867.48 16 438.71 422.60 16.11 3444.88 17 438.71 424.36 14.35 3020.52 18 438.71 426.12 12.59 2594.40 19 438.71 427.90 10.81 2166.50 20 438.71 429.68 9.03 1736.82 21 438.71 431.47 7.24 1305.35 22 438.71 433.27 5.44 872.08 23 438.71 435.08 3.63 437.00 24 438.82 437.00 1.82 0.00

Solution