//Savings and checking class import java.text.DecimalFormat; public class SavCheck extends Savings{ protected double checkBal; protected double checkRate; DecimalFormat prec = new DecimalFormat("0.00");//object to setup balance and rate public SavCheck() { checkBal = 0; checkRate = 0; } public SavCheck(int p, String n, double b, double r, double cb, double cr) { super(p,n,b,r); setCheckRate(cr); setCheckBal(cb); } public void setCheckBal(double cb)//set balance { checkBal = cb; } public double getCheckBal()//set check rate { return checkBal; } public void setCheckRate(double cRate)//set rate { checkRate = cRate; } public double getCheckRate()//get check rate { return checkRate; } public String update(boolean deposit, double value, int type) { double tempCBal = checkBal;//stores temporary balances of checking and savings double tempSBal = balance; if(type == 2){ if(deposit) { checkBal = checkBal + value; checkBal = checkBal + (checkBal * checkRate); return " Transaction Successful. Thank you, come again! "; } else { checkBal = checkBal - value; if(checkBal < 0) { checkBal = tempCBal; return " Transaction overdrawn. Get more money and try again. "; } else return " Transaction Successful. Thank you, come again! "; } } else if(type == 1) { if(deposit) { balance = balance + value; balance = balance + (balance * savRate); return " Transaction Successful. Thank you, come again! "; } else { balance = balance - value; if(balance < 0) { balance = tempSBal; return " Transaction overdrawn. Get more money and try again. "; } else return " Transaction Successful. Thank you, come again! "; } } else return "No Account exists.";//dont have these types of accounts } public String toString() { return super.toString() + "\tChecking Balance: " + prec.format(checkBal) + "\n"; } }// end boss class