Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA Create a menu-driven program using application to manage a bank account. It

ID: 3674163 • Letter: J

Question

JAVA

Create a menu-driven program using application to manage a bank account. It supports following operations:

Deposit money;

Withdraw money;

Check balance;

Add new account;

Delete account.

Application is driven by a text menu. Application stores the data in a .txt file. You must initial your .txt file with at least three accounts.

Data requirements:
It should have following attributes:

Account_no

Account_name

Balance

Note- use appropriate datatypes.

Required functionality: (User should be able to validate)

1. It should validate account_no to deposit money.
2. It should validate that, user cannot deposit negative amount.

3. It should validate account_no to withdraw money.

It should validate if amount to be withdrawn is less than the available funds in the account.

It should be able to add new account.

It should be able to delete existing account.

Finally, the menu should ask user to press key # to quit.

Remarks in program:

You must include remarks for every operations and attributes in your code

Explanation / Answer

import java.util.Scanner;

public class BankAccount {

      public static void main(String[] args) {

            Scanner in = new Scanner(System.in);

            int userChoice;

            boolean quit = false;

            float balance = 0f;

            do {

                  System.out.println("1. Deposit money");

                  System.out.println("2. Withdraw money");

                  System.out.println("3. Check balance");

                  System.out.print("Your choice, 0 to quit: ");

                  userChoice = in.nextInt();

                  switch (userChoice) {

                  case 1:

                        float amount;

                        System.out.print("Amount to deposit: ");

                        amount = in.nextFloat();

                        if (amount <= 0)

                             System.out.println("Can't deposit nonpositive amount.");

                        else {

                             balance += amount;

                             System.out.println("$" + amount + " has been deposited.");

                        }

                        break;

                  case 2:

                        System.out.print("Amount to withdraw: ");

                        amount = in.nextFloat();

                        if (amount <= 0 || amount > balance)

                             System.out.println("Withdrawal can't be completed.");

                        else {

                             balance -= amount;

                             System.out.println("$" + amount + " has been withdrawn.");

                        }

                        break;

                  case 3:

                        System.out.println("Your balance: $" + balance);

                        break;

                  case 0:

                        quit = true;

                        break;

                  default:

                        System.out.println("Wrong choice.");

                        break;

                  }

                  System.out.println();

            } while (!quit);

            System.out.println("Bye!");

      }

}