如何修复Java中用于可视化工作室代码的“错误:在应用程序类路径:Main上找到的类”
2022-09-02 23:53:48
这是我第一次在这里发帖,并希望如何解决此错误消息。它只出现有时,只允许我在一个名为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并更改类路径。
感谢您的关注。