import java.util.*; import java.awt.*; // // Savings account class // public class SavingsAccount extends MonthlyAccount { static final double transactionFee=1.0f; static final int freeTransactNo=3; int transactions; SavingsAccount(String accountname, double accountinterest, TextArea out) throws NoNameException { super(accountname,accountinterest,out); transactions=0; } void Deposit(double amount) throws NegativeAmountException { if(amount<0) throw new NegativeAmountException(new String(Name())); // impose fee transactions++; if(transactions>freeTransactNo) balance-=transactionFee; // update balance balance+=amount; } void Withdraw(double amount) throws MinBalanceException { if(balance-amount<0) throw new MinBalanceException(new String(Name())); // impose fee transactions++; if(transactions>freeTransactNo) balance-=transactionFee; // update balance balance-=amount; } void ComputeInterest() { //compute the interest (inherited method from MonthlyAccount) super.ComputeInterest(); transactions=0; // resets the # of transactions } void Update() { date=date%30+1; ComputeInterest(); } public void Output() { Double doubleNo=new Double(0); output.appendText("Savings account: "+Name()+"\nbalance: "+ doubleNo.toString(Balance())+"\nmonthly interest: "+ doubleNo.toString(interest)+"%\n"); } }