我已經嘗試過所有我能想到的事情來解決我的錯誤,但我完全難倒了。我不斷收到「類,接口或枚舉預期」錯誤。我錯過了什麼?類,接口或枚舉期望的錯誤
import java.until.*;
public class FutureValues {
public static final Scanner CONSOLE = new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Lab 3 written by JENNIFER ADAME");
System.out.println();
//declare variables
double p;
double r;
double y;
double f;
System.out.print("Enter present value: ");
double p = console.nextDouble();
System.out.print("Enter interest rate: ");
double r = console.nextDouble();
System.out.print("Enter number of years: ");
double y = console.nextDouble();
double f = compoundInterest(p, r, y);
System.out.print("The future value is" + f);
}
public static double compoundInterest (double p, double r, double y) {
double f = p * Math.pow(((1 + r)/100), y);
return f;
}
}
}
如果任何人都能幫上忙,那真是太棒了!
如果您正確縮進您的代碼,您的問題的答案將是顯而易見的。你在文件末尾有一個額外的'}'。 –