Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 accounts = new 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: BankProgram

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago

Question

=+from: a) a MNEs perspective? and b) the HRM managers perspective?

Answered: 1 week ago