Question
JAVA ONLY HELP ASAP PLEASE KEEPS PRODUCING THIS ERROR IN CODE This is the Main class import java.util.Scanner; import java.util.ArrayList; public class BankProgram { static
JAVA ONLY HELP ASAP PLEASE
KEEPS PRODUCING THIS ERROR IN CODE
This is the Main class
import java.util.Scanner; import java.util.ArrayList;
public class BankProgram { static Scanner sc = new Scanner(System.in); static ArrayList
public static void main(String[] args) { int choice = 0;
do { displayMenu(); choice = sc.nextInt();
switch (choice) { case 1: openCheckingAccount(); break; case 2: openSavingsAccount(); break; case 3: listAccounts(); break; case 4: accountStatement(); break; case 5: depositFunds(); break; case 6: withdrawFunds(); break; case 7: closeAccount(); break; case 8: System.out.println("Exiting program..."); break; default: System.out.println("Invalid choice, please try again."); } } while (choice != 8);
sc.close(); }
private static void closeAccount() { }
private static void withdrawFunds() { }
public static void displayMenu() { System.out.println("Please choose an option:"); System.out.println("1 - Open a Checking account"); System.out.println("2 - Open a Savings account"); System.out.println("3 - List Accounts"); System.out.println("4 - Account Statement"); System.out.println("5 - Deposit Funds"); System.out.println("6 - Withdraw Funds"); System.out.println("7 - Close an Account"); System.out.println("8 - Exit"); }
public static void openCheckingAccount() { System.out.println("Opening a new Checking Account."); System.out.print("Enter Account Number: "); int accountNumber = sc.nextInt(); System.out.print("Enter Initial Deposit: "); double initialDeposit = sc.nextDouble();
accounts.add(new CheckingAccount(accountNumber, initialDeposit)); System.out.println("Checking Account created successfully."); }
public static void openSavingsAccount() { System.out.println("Opening a new Savings Account."); System.out.print("Enter Account Number: "); int accountNumber = sc.nextInt(); System.out.print("Enter Initial Deposit: "); double initialDeposit = sc.nextDouble();
accounts.add(new SavingsAccount(accountNumber, initialDeposit)); System.out.println("Savings Account created successfully."); }
public static void listAccounts() { if (accounts.isEmpty()) { System.out.println("No accounts found."); return; }
System.out.println("Account Number\tAccount Type\tBalance"); for (Account acc : accounts) { System.out.println(acc.getAccountNumber() + "\t\t" + acc.getAccountType() + "\t\t" + acc.getBalance()); } }
public static void accountStatement() { System.out.print("Enter Account Number: "); int accountNumber = sc.nextInt();
Account account = findAccount(accountNumber); if (account == null) { System.out.println("Account not found."); return; }
System.out.println("Account Statement for Account Number " + accountNumber); System.out.println("Date\t\t\tDescription\t\tAmount"); for (Transaction trans : account.getTransactions()) { System.out.println(trans.getDate() + "\t" + trans.getDescription() + "\t" + trans.getAmount()); } }
private static Account findAccount(int accountNumber) { return null; }
public static void depositFunds() { System.out.print("Enter Account Number: "); int accountNumber = sc.nextInt();
Account account = findAccount(accountNumber); if (account == null) { System.out.println("Account not found."); return; }
System.out.print("Enter Deposit Amount: "); double depositAmount = sc.nextDouble();
account.deposit(depositAmount); System.out.println("Deposit successful. New balance: " + account.getBalance());
}
}
This is the Account class
public class Account {
public String getAccountNumber() { return getAccountNumber(); }
public String getAccountType() { return getAccountType(); }
public Transaction[] getTransactions() { return getTransactions(); }
public String getBalance() { return getBalance(); }
public void deposit(double depositAmount) { }
} This is the CheckingAccount class
public class CheckingAccount extends Account {
public CheckingAccount(int accountNumber, double initialDeposit) { }
}
This is the SavingsAccount class
public class SavingsAccount extends Account {
public SavingsAccount(int accountNumber, double initialDeposit) { }
}
This is the Transaction class
public class Transaction {
public String getDate() { return getDate(); }
public String getDescription() { return getDate(); }
public String getAmount() { return getAmount(); }
}
Error: Could not find or load main class BankProgram Caused by: java. lang.ClassNotFoundException: BankProgram Error: Could not find or load main class BankProgram Caused by: java. lang.ClassNotFoundException: BankProgramStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started