JAVA语言程序设计 第8版 复习题2.13 求高人指点
这是题目要求
这是我按照题目要求编写的代码
import java.util.Scanner;
public class ComputeFutureInvestmentValue
{
public static void main(String[] args)
{
// Create an new Scanner
Scanner input=new Scanner(System.in);
//提示输入投资总额
System.out.print("Enter investement amount:");
double investmentAmount=input.nextDouble();
//提示输入月利率
System.out.print("Enter monthly interest rate:");
double monthlyInvestmentRate=input.nextDouble();
//提示输入投资年限
System.out.print("Enter number of years:");
Integer numberOfyears=input.nextInt();
//计算未来的投资额
double futureInvestmentValue=investmentAmount*(Math.pow(1+monthlyInvestmentRate, numberOfyears*12));
//计算年利率
//double annualInterestRate=monthlyInvestmentRate*12;
//double futureInvestmentValue=investmentAmount*(Math.pow(1+annualInterestRate,numberOfyears));
//输出结果
System.out.println("Accumulated value is :" + " " +futureInvestmentValue);
}
}
但是按照书上说的输入后显示
红圈中的结果与书上的却不一样
求高人指点,是程序不对还是书上言之有误!!!!!!!!!!