Question
In JAVA, Given CODE need to be optmized Optimization and Exception Handling Refine Source Code for singular bank account program. Look for code optimization conventions
In JAVA, Given CODE need to be optmized
Optimization and Exception Handling
Refine Source Code for singular bank account program.
Look for code optimization conventions and syntax.
Catch all Exceptions generated during program run-time. The program should never exit with error message.
Bank Account Program
Create an Account Class
We are forming the skeleton of a more complex bank account program.
Create instance variables for balance.You may need more depending on how you implement your bank account program. (We will continue to update the program as the semester continues.)
Create an 2 arrays as a members of the class.
Deposit_Array
Withdraw_Array
We will need methods:
Method for Depositing values into the account.
What type of method will it be?
Method for Withdrawing values from the account.
What type of method will it be?
Method to output the balance of the account.
What type of method will it be?
Method that will output all deposits made to the account.
Method that will output all withdraws made from the account.
Add a new method that will output the contents of the bank account program to a text file.
Program will output the balance of the account.
Program will output the account withdrawals.
Program will output the account deposits.
Use class constructor to initialize values in programmer class for program execution.
Balance Value
Withdrawal History
Deposit History
Output should be like
**************************************
* Bank Account Program: *
* Enter # to run program or Quit *
* 1) Make a Deposit *
* 2) Make a Withdrawal *
* 3) Output balance *
* 4) Output all deposits *
* 5) Output all withdrawals *
* 6) Quit *
**************************************
This is the code that need to be optimized.
import java.io.*; import java.util.*;
class Account{
private ArrayList } public class Demo100{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); Account acc = new Account(); while (true){ System.out.println("1.Make a deposit"); System.out.println("2.Make a withdrawl"); System.out.println("3.Output balance"); System.out.println("4.Output all deposits"); System.out.println("5.Output all withdrawls"); System.out.println("6.Quit"); System.out.println("Enter option: "); int ch = Integer.parseInt(sc.nextLine()); if (ch == 6) break; if (ch == 1){ System.out.println("Enter deposit amount :"); double amt = Double.parseDouble(sc.nextLine()); acc.deposit(amt); } if (ch == 2){ System.out.println("Enter withdrwal amount :"); double amt = Double.parseDouble(sc.nextLine()); acc.withdrawl(amt); } if (ch == 3){ System.out.printf("Account Balance : %.2f", acc.getBalance()); System.out.println(); } if (ch == 4){ ArrayList
Step 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