Bifalgorithm post · Computer science one · Paying the Piper
What is 28?
What is 28? (Computer science one · Paying the Piper) — "28.5. Examples 28.5.4. Paying the Piper Let’s adapt the solution for the loan amortization schedule we…
Ideas in this flowchart
- Adaptation of a loan amortization schedule solution
- Read the principal, loan terms, and interest as command-line inputs.
- Calculate the monthly payment using the adapted formula and Math.pow().
- Accuracy problems can produce payments containing fractions of a cent.
- Currency values must be rounded to the nearest cent.
- Multiply the value by 100, round to a whole number, and divide by 100.
- In Java, round the monthly payment with Math.round(monthlyPayment * 100.0) / 100.0.
- Apply the same rounding technique to monthly interest and other currency values.
- Use System.out.printf() to format and align the output columns.
- Handle the final month separately to correct overpayment or underpayment caused by rounding.
- The complete adapted solution appears in Code Sample 28.10.