Slight tweak to remove the inlined /=.
class Loan { private final double monthlyPayment; Loan(int amount, int termYears, int termMonths, double annualInterest) { double val = amount * (annualInterest / 1200); annualInterest /= 1200; monthlyPayment = val / (1 - Math.pow(++annualInterest, -12 * termYears - termMonths)); } double getMonthlyPayment() { return monthlyPayment; } }
- class Loan {
- private final double monthlyPayment;
- Loan(int amount, int termYears, int termMonths, double annualInterest) {
monthlyPayment = amount * (annualInterest /= 1200) / (1 - Math.pow(++annualInterest, -12 * termYears - termMonths));- double val = amount * (annualInterest / 1200);
- annualInterest /= 1200;
- monthlyPayment = val / (1 - Math.pow(++annualInterest, -12 * termYears - termMonths));
- }
- double getMonthlyPayment() {
- return monthlyPayment;
- }
- }