这是我第一次在这里发帖,想知道如何解决此错误消息。它只是有时出现,并且只允许我在名为 Main.java 的程序上构建。我是一个初学者程序员所以请耐心等待,这是我试图运行的代码:
import java.util.Scanner;
import java.text.NumberFormat;
public class Main {
public static void main(String[] args) {
Scanner priceScanner = new Scanner(System.in);
System.out.print("Price: ");
int price = priceScanner.nextInt();
Scanner interestScanner = new Scanner(System.in);
System.out.print("Interest rate: ");
double interest = interestScanner.nextDouble();
Scanner numberOfPaymentsScanner = new Scanner(System.in);
System.out.print("Number of payments: ");
int numberOfPayments = numberOfPaymentsScanner.nextInt();
Double monthlyInterest = interest / 1200;
Double result = ((double)price * ((interest * Math.pow((1 +
interest), (double)numberOfPayments))/((Math.pow((1 + interest),
(double)numberOfPayments)) - 1)));
NumberFormat currency = NumberFormat.getCurrencyInstance();
String mortgage = currency.format(result);
System.out.println("Your mortgage is: " + mortgage);
}
}
我还没有在网上看到任何可以理解的方法来解决这个问题,我认为唯一可以解决它的方法是在另一个驱动器中重新安装 java 并更改类路径。
开满天机
陪伴而非守候
慕侠2389804
相关分类