継承を使用するコンストラクト クラスを作成していますが、 super()
. のInterestCalculator class
親である がありCompoundInterest Class
ます。複利クラスでを使用しようとしています。super()
コンストラクター InterestCalculator は3 つのパラメーター (元金、InterestRate、および期間)
を受け取ります。どのパラメーターを呼び出す必要があり、 3 つ (PrincipalAmount、InterestRate、および期間)を渡す必要がありCompoundInterest
ます。およびは に固有です。 4 parameters
4th parameter
CompoundInterest
import java.util.Scanner;
public class InterestCalculator
{
protected double principalAmount;
protected double interestRate;
protected int term;
public InterestCalculator(double principalAmount, double interestRate, int term)
{
this.principalAmount = principalAmount;
this.interestRate= interestRate;
this.term = term;
}
public double getPrincipal()
{
return principalAmount;
}
public double getInterestRate()
{
return interestRate;
}
public double getTerm()
{
return term;
}
public double calcInterest()
{
return -1;
}
protected double convertTermToYears()
{
return (this.term / 12.0);
}
protected double convertInterestRate()
{
return (this.interestRate / 100.0);
}
}
public class CompoundInterest extends InterestCalculator
{
protected int compoundMultiplier = 0;
super.CompoundInterest(double compoundMultiplier);
{
super.principalAmount = principalAmount;
super.interestRate = interestRate;
super.term = term;
this.compoundMultiplier = (int) compoundMultiplier;
}
public double calcInterest()
{
double calcInterest = (super.principalAmount *Math.pow((1.0+((super.convertInterestRate())/this.compoundMultiplier)),(this.compoundMultiplier *(super.convertTermToYears()))))- super.principalAmount;
return calcInterest;
}
}