gpt4 book ai didi

java - 数学难度

转载 作者:行者123 更新时间:2023-11-29 09:44:56 25 4
gpt4 key购买 nike

当我输入 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

关于java - 数学难度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11359160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com