my program seems to run fine the first time i run it, but when the JOptionPane box shows up at the end asking if id like to run it again it seems to restart my balance to the initial amount rather than keep it and continue subtracting or adding
import javax.swing.*;
import java.util.*;
class Chapter13_8{
public static void main(String []args){
SavingsAccount sa = new SavingsAccount();
boolean savingsInitial = false;
int accessSavings = 0, accessSavingsWithdraw = 0, accessSavingsDeposit = 0;
double savingsAmt = 0.0, savingsWithdrawAmount = 0.0, savingsDepositAmount = 0.0;
CheckingAccount ca = new CheckingAccount();
boolean checkingInitial = false;
int accessChecking = 0, accessCheckingWithdraw = 0, accessCheckingDeposit = 0;
double checkingAmt = 0.0, checkingWithdrawAmount = 0.0, checkingDepositAmount = 0.0;
int runAgain, cOrS;
boolean booleanAgain = false, savingsAgain, checkingAgain;
int savings = 0;
do{
savingsAgain = true;
checkingAgain = true;
if(booleanAgain){
cOrS = Integer.parseInt(JOptionPane.showInputDialog(null, "Would you like to use your Checking or Savings Account?\n1 - savings\n2 - checkings"));
if (cOrS == 1){
checkingAgain = false;
}
else if (cOrS == 2){
savingsAgain = false;
}
}
booleanAgain = false;
while(savingsAgain){
accessSavings = JOptionPane.showConfirmDialog(null, "Would you like to access your savings account?");
sa.SavingsAccount(savings);
if (accessSavings == 0){
if (savingsInitial == false){
savingsAmt = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter initial amound of money in savings account."));
savingsInitial = true;
}
sa.setInitial(savingsAmt);
accessSavingsWithdraw = JOptionPane.showConfirmDialog(null, "Would you like to withdraw from your savings account?");
if (accessSavingsWithdraw == 0){
savingsWithdrawAmount = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to withdraw?"));
}
sa.withdraw(savingsWithdrawAmount);
accessSavingsDeposit = JOptionPane.showConfirmDialog(null, "Would you like to deposit to your savings account?");
if (accessSavingsDeposit == 0){
savingsDepositAmount = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to deposit?"));
}
sa.deposit(savingsDepositAmount);
}
savingsAgain = false;
savings++;
}
while(checkingAgain){
accessChecking = JOptionPane.showConfirmDialog(null, "Would you like to access your checking account?");
if (accessChecking == 0){
if (checkingInitial == false){
checkingAmt = Double.parseDouble(JOptionPane.showInputDialog(null, "Enter initial amound of money in checking account."));
checkingInitial = true;
}
ca.setInitial(checkingAmt);
accessCheckingWithdraw = JOptionPane.showConfirmDialog(null, "Would you like to withdraw from your checking account?");
if (accessCheckingWithdraw == 0){
checkingWithdrawAmount = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to withdraw?"));
}
ca.withdraw(checkingWithdrawAmount);
accessCheckingDeposit = JOptionPane.showConfirmDialog(null, "Would you like to deposit to your checking account?");
if (accessCheckingDeposit == 0){
checkingDepositAmount = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to deposit?"));
}
ca.deposit(checkingDepositAmount);
}
checkingAgain = false;
}
runAgain = JOptionPane.showConfirmDialog(null, "Would you like to use any of your accounts again?");
if (runAgain == 0){
booleanAgain = true;
}
} while (booleanAgain);
System.out.println(sa);
System.out.println(ca);
}
}
public void withdraw(double n){
if (limit < 20){
while (n > balance){
JOptionPane.showMessageDialog(null, "Not Enough Money!");
n = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to withdraw?"));
}
balance -= (n + CHECK_FEE);
}
else if (limit >= 20){
while (n > balance){
JOptionPane.showMessageDialog(null, "Not Enough Money!");
n = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to withdraw?"));
}
balance -= n;
}
}
public void withdraw(double n){
if (limit < 3){
while (n > balance){
JOptionPane.showMessageDialog(null, "Not Enough Money!");
n = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to withdraw?"));
}
balance -= n;
}
else if (limit >= 3){
while (n > balance){
JOptionPane.showMessageDialog(null, "Not Enough Money!");
n = Double.parseDouble(JOptionPane.showInputDialog(null, "How much would you like to withdraw?"));
}
balance -= (n + WITHDRAWL_CHARGE);