我试图返回变量val并在不使用print语句的情况下打印出未来值,编译器说它很好但不会返回值。
import java.util.Scanner;
public class FutureValues{
public static Scanner scan = new Scanner( System.in);
public static void main(String[] args){
double currentAmount = scan.nextDouble();
double rate = scan.nextDouble();
double year = scan.nextDouble();
FutureValue(currentAmount,rate,year);
}
public static double FutureValue(double p, double r, double y){
double rate = r/100.0;
double fv = p*(1 + rate);
double val = Math.pow(fv,y);
return val;
}
}