While it would be nice for the banks if interest were calculated this way, this is not how simple interest is calculated. The Calculation in the example shown on the website is correct (one minor typo Debt mortgage = new Debt(120000.0, 1.01); should be Debt mortgage = new Debt(120000.0, 1.0); for the calculations shown to work correctly).
In DebtTest.java,
in waitOneYearChangesTheBalance() the line
double expected = 1500.0 * 2.0;
should read:
double expected = 1500.0 + (1500 * .02)
and in waitOneYearChangesTheBalance2() the line
double expected = 1500.0 * 2.0 * 2.0;
should read:
double expected = 1500 + (1500.0 * .02) + ((1500 + (1500.0 * .02)) * .02);
While it would be nice for the banks if interest were calculated this way, this is not how simple interest is calculated. The Calculation in the example shown on the website is correct (one minor typo
Debt mortgage = new Debt(120000.0, 1.01);
should beDebt mortgage = new Debt(120000.0, 1.0);
for the calculations shown to work correctly).In DebtTest.java, in waitOneYearChangesTheBalance() the line
double expected = 1500.0 * 2.0;
should read:double expected = 1500.0 + (1500 * .02)
and in waitOneYearChangesTheBalance2() the line
double expected = 1500.0 * 2.0 * 2.0;
should read:double expected = 1500 + (1500.0 * .02) + ((1500 + (1500.0 * .02)) * .02);
DebtTest.java.txt