我编写了一个简单的程序,它接收多个输入并进行未来投资计算。
但是,由于某种原因,当我输入以下值时:投资 = 1 利息 = 5 年 = 1
我知道Your future value is 65.34496113081846
什么时候应该是 1.05。
import java.util.*;
public class futurevalue
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("This program will calculate your future investment value");
System.out.println("Enter investment amount: ");
double investment = sc.nextDouble();
System.out.println("Enter annual interest amount: ");
double interest = sc.nextDouble();
System.out.println("Enter number of years: ");
int year = sc.nextInt();
double futureValue = investment * (Math.pow(1 + interest, year*12));
System.out.println("Your future value is " + futureValue);
}
}
发现我的错误。我分了两次兴趣。