Hello! I'm having some difficulty with my bank account project. I'm supposed to create a menu where the user can create a new account, withdraw, deposit, view their balance, and exit. There's issues with the account creation. Can someone please help me fix this problem?
Here's my necessitated class below: BankAccount, TestBankAccount, SavingsAccount, CurrentAccount, and Bank
/*--------------------------------------------------- Name: Christian Bethel Student ID: T19170213 COP 2800 - Java Programming Fall 2014 - T Th 6:00PM - 9:20PM Project 3 Plagiarism Statement I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons. ----------------------------------------------------------*/ package BankAccount; import java.util.Date; import java.util.Random; //Project 3 public class BankAccount { protected static int accountID; protected static double accountBalance; private static double annualInterestRate; public static Date dateCreated = new Date(); static String name = new String(); private static String password = new String(); Random RandomNumber = new Random(); BankAccount() { accountID = 1000 + (int) (Math.random() * 9000); String myAccountID = accountID + ""; } BankAccount(double AccountBalance) { accountID = (int) (Math.random() * 9000); String myAccountID = accountID + ""; accountBalance = AccountBalance; } public static void setAccountBalance(double newAccountBalance) { accountBalance = newAccountBalance; } public static double getAccountBalance() { return accountBalance; } static void withdraw(double withdrawAmount) { if (accountBalance == 0 && withdrawAmount > accountBalance) System.out.println("Insufficient Funds!!!" + accountBalance); if (accountBalance == 0 ^ withdrawAmount > accountBalance) System.out .println("Hey! You can't take out more than you already have!\n" + accountBalance); accountBalance -= withdrawAmount; } static double deposit(double depositAmount) { return accountBalance += depositAmount; } public static void setAnnualInterestRate(double yourAnnualInterestRate) { annualInterestRate = yourAnnualInterestRate; } public double getAnnualInterestRate() { return annualInterestRate; } public static int getAccountID() { return accountID; } public static Date getDateCreated() { return dateCreated; } static double getMonthlyInterestRate() { return annualInterestRate / 12; } public static String getName() { return name; } public static void setName(String myName) { name = myName; } static void setPassword() { Random idGenerator = new Random(System.currentTimeMillis()); char[] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); String password = ""; for (int i = 1; i <= 4; i++) password += letters[idGenerator.nextInt(27)]; } public static String getPassword() { return password; } } /*--------------------------------------------------- Name: Christian Bethel Student ID: T19170213 COP 2800 - Java Programming Fall 2014 - T Th 6:00PM - 9:20PM Project 3 Plagiarism Statement I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons. ----------------------------------------------------------*/ package BankAccount; import java.util.Scanner; //Project 3 public class TestBankAccount { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("-Main Menu-\n" + "1.Create New Account" + " 2.Deposit" + " 3.Withdraw\n" + "4.Display Balance" + " 5.Open/Close an Account" + " 6.Exit\n" + "What would you like to do? "); int Choice = input.nextInt(); switch (Choice) { case 1: System.out.println("Please enter your name: "); String Name = input.nextLine(); BankAccount.setName(Name); BankAccount.setPassword(); System.out.println("Your Credentials\n" + "Name: " + BankAccount.getName() + "\n" + "Password: " + BankAccount.getPassword()); BankAccount regularAccount = new BankAccount(); Bank.bankAccounts.add(regularAccount); TestBankAccount.main(null); break; case 2: System.out.println("Enter the amount you wish to deposit: "); double DepositAmount = input.nextDouble(); BankAccount.deposit(DepositAmount); System.out.println("Balance: " + "$" + BankAccount.getAccountBalance() + "0"); TestBankAccount.main(null); break; case 3: System.out.println("Enter the amount you wish to withdraw: "); double WithdrawAmount = input.nextDouble(); BankAccount.withdraw(WithdrawAmount); System.out.println("Balance: " + "$" + BankAccount.getAccountBalance() + "0"); TestBankAccount.main(null); break; case 4: System.out.println("Balance: " + "$" + BankAccount.getAccountBalance() + "0" + "\n" + "Monthly Interest Rate: " + BankAccount.getMonthlyInterestRate() * 100 + "%" + "\n" + "Created On: " + BankAccount.getDateCreated() + "\n" + "AccountID: " + BankAccount.getAccountID()); TestBankAccount.main(null); break; case 5: System.out.println("Would you like to open or close an account?\n" + "1.Open\n" + "2.Close\n"); int accountOption = input.nextInt(); if (accountOption == 1) Bank.openAccount(); else if (accountOption == 2) Bank.closeAccount(); else System.out.println("Invalid. Try again!"); TestBankAccount.main(null); break; case 6: System.out.println("Do you want to exit?\n" + "1. Yes\n" + "2. No"); int ExitChoice = input.nextInt(); switch (ExitChoice) { case 1: System.exit(0); break; case 2: TestBankAccount.main(null); break; default: System.out.print("Ivnalid. Try Again!"); break; } } } } /*--------------------------------------------------- Name: Christian Bethel Student ID: T19170213 COP 2800 - Java Programming Fall 2014 - T Th 6:00PM - 9:20PM Project 3 Plagiarism Statement I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons. ----------------------------------------------------------*/ package BankAccount; import java.util.Date; import java.util.Random; public class SavingsAccount extends BankAccount { protected static double interest; private static int accountID; protected static double accountBalance; private static double annualInterestRate; static Date dateCreated = new Date(); private static String name = new String(); private static String password = new String(); Random RandomNumber = new Random(); SavingsAccount() { super(); accountID = (int) (Math.random() * 10000); String myAccountID = accountID + ""; } SavingsAccount(double accountBalance) { super(); accountID = (int) (Math.random() * 10000); String myAccountID = accountID + ""; } public static void setAccountBalance(double newAccountBalance) { accountBalance = newAccountBalance; } public static void addInterest(double interest) { BankAccount.accountBalance += (interest * 12); } public static double getAccountBalance() { return accountBalance; } static void withdraw(double withdrawAmount) { if (accountBalance == 0) System.out.println("Insufficient Funds!!!"); if (withdrawAmount > accountBalance) System.out .println("Hey! You can't take out more than you already have!"); accountBalance -= withdrawAmount; } static double deposit(double depositAmount) { return accountBalance += depositAmount; } public static void setAnnualInterestRate(double yourAnnualInterestRate) { annualInterestRate = yourAnnualInterestRate; } @Override public double getAnnualInterestRate() { return annualInterestRate; } public static int getAccountID() { return accountID; } public static Date getDateCreated() { return dateCreated; } static double getMonthlyInterestRate() { return annualInterestRate / 12; } public static String getName() { return name; } public static void setName(String name) { } static String generatePassword() { Random idGenerator = new Random(System.currentTimeMillis()); char[] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); String password = ""; for (int i = 1; i <= 4; i++) password += letters[idGenerator.nextInt(27)]; return password; } public static String getPassword() { return password; } } /*--------------------------------------------------- Name: Christian Bethel Student ID: T19170213 COP 2800 - Java Programming Fall 2014 - T Th 6:00PM - 9:20PM Project 3 Plagiarism Statement I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons. ----------------------------------------------------------*/ package BankAccount; import java.util.Date; import java.util.Random; public class CurrentAccount extends BankAccount { private static int accountID; protected static double accountBalance; private static double annualInterestRate; protected static double overdraftLimit = 500.0; static Date dateCreated = new Date(); private static String name = new String(); private static String password = new String(); Random RandomNumber = new Random(); CurrentAccount() { super(); accountID = (int) (Math.random() * 10000); String myAccountID = accountID + ""; } CurrentAccount(double accountBalance) { super(); accountID = (int) (Math.random() * 10000); String myAccountID = accountID + ""; } public static void setAccountBalance(double newAccountBalance) { accountBalance = newAccountBalance; } public static double getAccountBalance() { return accountBalance; } public static void withdraw(double withdrawAmount) { if (accountBalance == 0) System.out.println("Insufficient Funds!!!"); if (withdrawAmount > accountBalance) System.out .println("Hey! You can't take out more than you already have!"); accountBalance -= withdrawAmount; } public static double deposit(double depositAmount) { return accountBalance += depositAmount; } public static void setAnnualInterestRate(double yourAnnualInterestRate) { annualInterestRate = yourAnnualInterestRate; } @Override public double getAnnualInterestRate() { return annualInterestRate; } public static int getAccountID() { return accountID; } public static Date getDateCreated() { return dateCreated; } public static double getMonthlyInterestRate() { return annualInterestRate / 12; } public static String getName() { return name; } public static void setName(String name) { } public static String generatePassword() { Random idGenerator = new Random(System.currentTimeMillis()); char[] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); String password = ""; for (int i = 1; i <= 4; i++) password += letters[idGenerator.nextInt(27)]; return password; } public static String getPassword() { return password; } } /*--------------------------------------------------- Name: Christian Bethel Student ID: T19170213 COP 2800 - Java Programming Fall 2014 - T Th 6:00PM - 9:20PM Project 3 Plagiarism Statement I certify that this assignment is my own work and that I have not copied in part or whole or otherwise plagiarized the work of other students and/or persons. ----------------------------------------------------------*/ package BankAccount; import java.util.ArrayList; import java.util.Scanner; public class Bank { static ArrayList<Object> bankAccounts = new ArrayList<>(3); public static void update() { for (int i = 0; i < bankAccounts.size(); i++) { if (bankAccounts.get(i) instanceof SavingsAccount) SavingsAccount.addInterest(SavingsAccount.interest); else if (bankAccounts.get(i) instanceof CurrentAccount) System.out.print("You have reached your overdraft limit!"); } } public static void openAccount() { Scanner input = new Scanner(System.in); System.out.println("What type of account would you like to open?\n" + "1.Regular Account" + " 2.Savings Account\n" + "3.Current Account" + " 4.Update Accounts"); int choice = input.nextInt(); switch (choice) { case 1: BankAccount newBankAccount = new BankAccount( BankAccount.accountBalance); bankAccounts.add(newBankAccount); break; case 2: SavingsAccount newSavingsAccount = new SavingsAccount( SavingsAccount.accountBalance); bankAccounts.add(newSavingsAccount); break; case 3: CurrentAccount newCurrentAccount = new CurrentAccount( CurrentAccount.accountBalance); bankAccounts.add(newCurrentAccount); break; case 4: Bank.update(); break; default: System.out.println("Invalid. Try again!"); System.exit(0); break; } } public static void closeAccount() { Scanner input = new Scanner(System.in); System.out.println("What is your name?"); String myName = input.nextLine(); System.out.println("What is your ID?"); int ID = input.nextInt(); if (ID == BankAccount.accountID && myName.equals(BankAccount.name)) bankAccounts.remove(bankAccounts.size() - 1); else System.exit(0); } }