I got this so far. What am I doing wrong?
public class Polymorphism
{
public static void main(String[] args)
{
Guarantee guarantee1= new Guarantee();
CompoundInterest compoundInterest1= new CompoundInterest();
Loan loan1=new Loan();
Scanner input= new Scanner( System.in);
double principle;
double rate;
int years;
System.out.print("Enter principle:");
principle= input.nextDouble();
System.out.print("Enter rate:");
rate= input.nextDouble();
System.out.print("Enter years:");
years= input.nextInt();
guarantee1.setPrincipleAmount(principle);
guarantee1.setInterestEarned(rate, years);
System.out.printf("principle amount of %.2f, An interest rate of %f, you would have earned %.2f",principle, rate, guarantee1.getInterestEarned() );
System.out.print("Enter principle:");
principle= input.nextDouble();
System.out.print("Enter rate:");
rate= input.nextDouble();
System.out.print("Enter years:");
years= input.nextInt();
compoundInterest1.setCompoundInterest(rate,years);
System.out.printf("Principle amount of %.2f, An interest rate of %.2f, you would have earned %.2f", principle, rate, compoundInterest1.getCompoundInterest());
}
}
abstract class Funds
{
public double principleAmount;
public void setPrincipleAmount(double principle)
{
principleAmount =principle;
}
public double setPrincipleAmount()
{
return principleAmount;
}
}
class Guarantee extends Funds
{
public double InterestEarned;
public void setInterestEarned(double rate,int years)
{
InterestEarned= principleAmount*rate*years;
}
public double getInterestEarned()
{
return InterestEarned;
}
}
class CompoundInterest extends Funds
{
public double CompoundInterest;
public void setCompoundInterest(double rate,int years)
{
CompoundInterest = principleAmount * Math.pow((1+rate),years);
}
public double getCompoundInterest()
{
return CompoundInterest;
}
}
class Loan extends Funds
{
public double totalLoanAmount;
public void setTotalLoanAmount(double rate, int years)
{
totalLoanAmount = principleAmount*rate*years +principleAmount;
}
public double getTotalLoanAmount()
{
return totalLoanAmount;
}
}