import java.text.DecimalFormat; /** * class savings extends account * * john sloan * january 24, 2009 */ public class savings extends account { private double interestRate; private DecimalFormat f; /** * constructor */ public savings(String Name, int number, double balance, double setRate) { super(Name, number,1,balance); interestRate = setRate; f = new DecimalFormat(); f.applyPattern( "##0.00%;-##0.00%"); } /** * method */ public void deposit(double deposit) { super.deposit(deposit); } /** * method withdrawl */ public void withdrawl(double withdrawl) { double temp=(balance - withdrawl); if(temp<=0){ System.out.print("Insufficient Funds"); } else{ super.withdrawl(withdrawl); } } /** * method addInterest */ public void addInterest() { balance = balance + (balance * interestRate); } /** * method setInterest */ public void setInterest(double rate) { interestRate = rate; } /** * method getInterestRate */ public double getInterest() { return interestRate; } /** * Calls Print Method in account base */ public void print() { super.print(); System.out.println("The interest rate is: " + (f.format(interestRate)) ); System.out.println(); } }