I am very lost with this program. It is supposed to set up a savings and checking account, withdraw the specified amounts and throw the specified exceptions when an overdraft occurs.
Issue 1: I can not get the SavingsAccount and CheckingAccount classes to take in the int, double, double from the driver program. Only the int id variable is being passed.
Issue 2: The withdraw and deposit that are supposed to throw the exeptions are not working.
//I commented the exeptions out until I can get the other pieces working.
Any help offered would be appriciated.
Issue 1: I can not get the SavingsAccount and CheckingAccount classes to take in the int, double, double from the driver program. Only the int id variable is being passed.
Issue 2: The withdraw and deposit that are supposed to throw the exeptions are not working.
//I commented the exeptions out until I can get the other pieces working.
Any help offered would be appriciated.
package Banking; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class AccountDriver { public static void main(String[] args) { CheckingAccount ck1 = new CheckingAccount(1122,1000.00,.045); SavingsAccount sav1 = new SavingsAccount(1123,20000.00,.045); JOptionPane.showMessageDialog(null, "Checking Account Created"); JOptionPane.showMessageDialog(null, "Savings Account Created"); System.out.println(ck1.toString()); System.out.println(sav1.toString()); ck1.deposit(3000.00); ck1.withdraw(5000.00); sav1.deposit(3000); sav1.withdraw(5000.00); }//end main } //ends class package Banking; import javax.swing.JOptionPane; public class Account { public int id; public double balance; public double annualInterestRate; public Account() { }//close default constructor public Account(int id, double balance) { this.id = id; this.balance = balance; }//closes specified constructor public int getid() { return id; } //closes getid getter public void setid(int id) { this.id = id; }//closes setid setter public double getbalance() { return balance; }//closes get balance public void setbalance(double balance) { this.balance = balance; }//closes balance setter public double getannualInterestRate() { return annualInterestRate; }//closes AIR getter public void setAnnualInterestRate(double annualInterestRate) { this.annualInterestRate = annualInterestRate; }//closes AIR setter public void withdraw(double withdraw) { balance = balance - withdraw; } public void deposit(double deposit) { balance = balance + deposit; } } package Banking; import javax.swing.JOptionPane; public class CheckingAccount extends Account { double withdraw; double deposit; double balance; double annualInterestRate; double defaultOverdraft = -100.00; double newBalance; public CheckingAccount() { } public CheckingAccount(int id, double balance, double annualInterestRate){ super.deposit(deposit); super.withdraw(withdraw); super.setAnnualInterestRate(annualInterestRate); super.setid(id); super.setbalance(balance); /*try { if (newBalance < defaultOverdraft) throw new IllegalArgumentException("Insufficient Funds"); else JOptionPane.showMessageDialog(null, "Transaction Complete " + "/nPrevious Balance: " + balance + "/nNew Balance: " + newBalance); } catch(IllegalArgumentException ex) { JOptionPane.showMessageDialog(null, "Insufficient Funds to Execute Transaction - No Withdraw from Savings Processed"); }*/ } public void setdeposit(double deposit) { this.deposit = deposit; } public double getdeposit() { return deposit; } public void setwithdraw(double withdraw){ this.withdraw = withdraw; } public double getwithdraw() { return withdraw; } public double getbalance(double newBalance) { return (balance + deposit - withdraw); } public double getannualInterestRate(double annualInterestRate){ return annualInterestRate; } public String toString() { return String.format("Account ID: " + "" + id + " Current Balance: " + "" + balance + " InterestRate: " + "" + annualInterestRate); } } package Banking; import javax.swing.JOptionPane; public class SavingsAccount extends Account { double withdraw; double deposit; double balance; double annualInterestRate; public SavingsAccount() { } public SavingsAccount(int id, double balance, double annualInterestRate){ super.deposit(deposit); super.withdraw(withdraw); super.setAnnualInterestRate(annualInterestRate); super.setid(id); super.setbalance(balance); }//ends overloaded Savings Account /* try { if (withdraw > balance) throw new IllegalArgumentException("Insufficient Funds"); else JOptionPane.showMessageDialog(null, "Transaction Complete " + "/nPrevious Balance: " + balance + "/nNew Balance: " + newbalance); } catch(IllegalArgumentException ex) { JOptionPane.showMessageDialog(null, "Insufficient Funds to Execute Transaction - No Withdraw from Savings Processed"); }*/ public void setdeposit(double deposit) { this.deposit = deposit; } public double getdeposit() { return deposit; } public void setwithdraw(double withdraw){ this.withdraw = withdraw; } public double getwithdraw() { return withdraw; } //public double getbalance(double newBalance) { //return (balance + deposit - withdraw); //} public String toString() { return String.format("Account ID: " + "" + id + " Current Balance: " + "" + balance + " InterestRate: " + "" + annualInterestRate); } }