これは複利計算機です。現在のように長い数ではなく、小数点以下 2 桁だけの答えを得る方法を理解できないことを除いて、すべて正常に機能します。コードを見て、修正する必要があるかどうかを提案してください。どうもありがとうございました。
class InvestmentProject{
public double CompoundInterest(double InitialDeposit, double YearlyContribution, double InterestRate, int PeriodsInYr) {
double RateInDecimal = InterestRate/100;
double Value = YearlyContribution/RateInDecimal - YearlyContribution/(RateInDecimal * Math.pow(1 + RateInDecimal, PeriodsInYr));
return (InitialDeposit + Value) * Math.pow(1 + RateInDecimal, PeriodsInYr);
}
}