//Savings class import java.text.DecimalFormat; public class Savings extends Account{ protected double balance; protected double savRate; DecimalFormat prec = new DecimalFormat("0.00");//object to setup balance and rate public Savings() { balance = 0; savRate = 0; } public Savings(int p, String n, double b, double r) { super(p,n); setBal(b); setRate(r); } public void setBal(double b)//set balance { balance = b; } public double getBal()//get balance { return balance; } public void setRate(double rate)//set rate { savRate = rate; } public double getRate()//get rate { return savRate; } public String update(boolean deposit, double value, int type) { double tempBal = balance;//store balance in case account is overdrawn if(type == 1){ if(deposit) { balance = balance + value; balance = balance + (balance * savRate);//adds rate to balance return " Transaction Successful. Thank you, come again! "; } else { balance = balance - value; if(balance < 0) { balance = tempBal;//since overdrawn, don't update balance return " Transaction overdrawn. Get more money and try again. "; } else return " Transaction Successful. Thank you, come again! "; } } else return "No Account exists."; } public String toString() { return super.toString() + "\tSavings Balance: $" + prec.format(balance) + "\n"; } }// end boss class