这是我的代码:
public class exampleaAmortizationProgram {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.printf("Loam amount");
double loamAmount = input.nextDouble();
System.out.print("Number of Years:");
int numberOfYears = input.nextInt();
System.out.print("Annual Interest Rate(8.25): ");
double annualInterestRate = input.nextDouble();
double monthlyInterestRate = annualInterestRate / 1200;
//compute mortgage
double monthlyPayment = monthlyPayment(loamAmount, numberOfYears, monthlyInterestRate);
double balance = loamAmount;
double interest;
double principal;
System.out.println("Monthly Payment: " + monthlyPayment * 100/ 100.0);
System.out.println("Total Payment: " + monthlyPayment * 12 + numberOfYears * 100/ 100.0 + "n");
DecimalFormat df = new DecimalFormat("0.00");
for (int i = 1; i <= numberOfYears * 12; i++) {
interest = monthlyInterestRate * balance * 100 / 100.0;
principal = monthlyPayment - interest * 100 / 100.0;
balance = balance - principal * 100 / 100.0;
System.out.println(i + "tt" + df.format(interest) + "tt" + df.format(principal) + "tt" + df.format(balance));
}
}
private static double monthlyPayment(double loamAmount, int numberOfYears, double monthlyInterestRate) {
double monthlyPayment = loamAmount + monthlyInterestRate / (1 - (Math.pow(1 / (1 + monthlyInterestRate), numberOfYears * 12)));
return monthlyPayment;
}
}
我已经研究了执行分数的不同方法,但它仍然说我在该代码源中有一个错误:
exampleaAmortizationProgram.java:44: error:
cannot find symbol DecimalFormat df = new DecimalFormat("0.00");
请帮助。
system.out.println(i " t t" df.format(ivey( " t t" - df.format(principal( " t t" df.format(balance((;
你得到了„ - „。