이것은 복리 계산 계산기입니다. 단, 소수점 이하 두 자리 만 있으면서 내 대답을 얻는 방법을 알 수 없다는 점을 제외하고는 모든 것이 잘 작동합니다. 코드를 살펴보고 올바른 것이 무엇이 있는지 제안하십시오. 고맙습니다.Java 프로그래밍, 소수점 숫자
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);
}
}