當我爲每月利率和1年的投資金額4.25輸入1000時,爲什麼我會得到結果4.384414858452464E11而不是預期的1043.34?Math.pow難度
import java.util.Scanner;
public class FinancialApplicationFutureInvestment_13 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter investment amount: ");
int investmentAmount = input.nextInt();
System.out.println("Enter monthly interest rate: ");
double monthlyInterestRate = input.nextDouble();
System.out.println("Enter number of years");
int numOfYears = input.nextInt();
double futureInvestmentValue = investmentAmount *
(Math.pow(1 + monthlyInterestRate, numOfYears * 12));
System.out.println("Accumulated value is: " + futureInvestmentValue);
double test = Math.pow(1 + monthlyInterestRate, numOfYears * 12);
System.out.println(test);
}
}
你在哪兒'1043.34'?如果我按照下面的建議將利率除以100,那麼我得到了'1647.83'。 – Keppil 2012-07-06 09:10:27
每月4.25%〜64.7%每年。這應該會產生很大的結果。 – 2012-07-06 09:31:46