当我输入1000作为投资利率4.25作为月利率,并输入1作为年份时,为什么我得到的结果是4.384414858452464E11,而不是预期的1043.34?

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);
    }
}

最佳答案

每月利率可能需要输入为0.0425

10-06 06:08
查看更多