|
311 | 311 | int numberOfPayments = years * MONTHS_IN_YEAR;
|
312 | 312 |
|
313 | 313 | /*calculating mortgage*/
|
314 |
| - double mortgage = principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
| 314 | + double mortgage = principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) |
| 315 | + / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
315 | 316 |
|
316 | 317 | System.out.println("Mortgage: " + NumberFormat.getCurrencyInstance().format(mortgage));
|
317 | 318 | }
|
|
562 | 563 |
|
563 | 564 | }
|
564 | 565 | /*calculating mortgage*/
|
565 |
| - double mortgage = principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
| 566 | + double mortgage = principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) |
| 567 | + / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
566 | 568 |
|
567 | 569 | System.out.println("Mortgage: " + NumberFormat.getCurrencyInstance().format(mortgage));
|
568 | 570 | }
|
|
618 | 620 | float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;
|
619 | 621 | short numberOfPayments = (short) (years * MONTHS_IN_YEAR);
|
620 | 622 |
|
621 |
| - return principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
| 623 | + return principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) |
| 624 | + / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
622 | 625 | }
|
623 | 626 | }
|
624 | 627 | ```
|
|
676 | 679 | float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;
|
677 | 680 | short numberOfPayments = (short) (years * MONTHS_IN_YEAR);
|
678 | 681 |
|
679 |
| - double balance = principal * (Math.pow(1 + monthlyInterest, numberOfPayments) - Math.pow(1 + monthlyInterest, numberOfPaymentsMade)) / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1); |
| 682 | + double balance = principal * (Math.pow(1 + monthlyInterest, numberOfPayments) |
| 683 | + - Math.pow(1 + monthlyInterest, numberOfPaymentsMade)) |
| 684 | + / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1); |
680 | 685 |
|
681 | 686 | return balance;
|
682 | 687 | }
|
|
685 | 690 | float monthlyInterest = annualInterest / PERCENT / MONTHS_IN_YEAR;
|
686 | 691 | short numberOfPayments = (short) (years * MONTHS_IN_YEAR);
|
687 | 692 |
|
688 |
| - return principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
| 693 | + return principal * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments) |
| 694 | + / (Math.pow(1 + monthlyInterest, numberOfPayments) - 1)); |
689 | 695 | }
|
690 | 696 | }
|
691 | 697 | ```
|
|
710 | 716 |
|
711 | 717 | ## Thank You!
|
712 | 718 |
|
713 |
| - |
| 719 | + |
0 commit comments