(Solved) : Instructions Using Bcexceptionjava Bankcustomerjava First Part Assignment Implement Driver Q44017954 . . .
Instructions
Using the BCException.java and theBankCustomer.java from the first part of theassignment you will implement a driver class calledBank.java to manipulate an ArrayList ofBankCustomer objects.
Your code should read bank customers’ information from the user.It will then create a bank customer objects and add them to anarraylist in a sorted fashion (sorted by account number).The arraylist should be sorted in ascending order atall times. The arraylist should not contain nullobjects at any point. You may NOT add a BankCustomer and then sortthe arraylist, you should insert the new element in the appropriateposition. The arraylist should not contain duplicate bankcustomers. For the purpose of this assignments duplicate bankcustomers are those that have the same account number.
When removing a bank customer you should find the customer usingthe account number. You will search for the account number and iffound, delete the customer from the arraylist. If not found youshould display a message saying so and go back to the mainmenu.
Printing all the bank customers should be done in ascendingorder, which is the same way that the arraylist is sorted.
Bank.java should not end execution if anexception happens. You should handle exceptions gracefully.Execution should end only when the user decides to exit byselecting 0 from the menu. (50 points)
Your code should display the following menu:
1. Add a bank customer (50points)
2. Remove a bank customer (50points)
3. Print all bank customers (50points)
0. Exit
The program should end only when the user selects 0 to exit,otherwise the menu should continue to loop executing options asselected by the user. Feel free to use any extra helper/staticmethods to make your code more efficient and legible. Not required,but you may want to do it for extra credit, as extra credit isgiven for well-written code.
You should submit the driver class as well as yourBankCustomer.java and BCException.java (again) (40points). If previously, your code allowed for the creation ofinvalid objects you must review and fix your code or you will getdeductions in this assignment as well.
Below is my BankCustomer.java andBCException.java
BankCustomer.java
public class BankCustomer {
private int acctNumber;
private double balance;
private String name;
public BankCustomer(int acctNumber, double balance, String name)throws Exception{
this.setAcctNumber(acctNumber);
this.setBalance(balance);
this.setName(name);
}
public BankCustomer(){
this.acctNumber = 10001;
this.balance = 120.0;
this.name = “sample”;
}
public void setAcctNumber(int acctNumber) throws Exception {
if (acctNumber >= 10001 && acctNumber <=99999){
this.acctNumber = acctNumber;
}
else{
BCException me = new BCException();
me.setMessage(“The account number passed ” + acctNumber + ” is notvalid”);
throw (me);
}
}
public void setBalance(double balance) throws Exception {
if (balance >= 100){
this.balance = balance;
}
else {
BCException me = new BCException();
me.setMessage(“The amount added ” + balance + ” should be more than100″);
throw (me);
}
}
public void setName(String name) throws Exception {
if (name.trim().length() >= 5){
this.name = name.trim();
}
else {
BCException me = new BCException();
me.setMessage(“The name ” + name + ” should be atleast 5 non-blankcharacters”);
throw (me);
}
}
public int getAcctNumber() {
return acctNumber;
}
public double getBalance() {
return balance;
}
public String getName() {
return name;
}
}
BCException.java
public class BCException extends Exception{
//one instance variable
private String message;
public void setMessage(String message){
this.message = message;
}
public String getMessage(){
return this.message;
}
}
Please help me create a driver class plus the array requirementthat is needed based on the instruction given plus ” You shouldsubmit the driver class as well as your BankCustomer.java andBCException.java (again) (40 points). If previously, yourcode allowed for the creation of invalid objects you must reviewand fix your code or you will get deductions in this assignment aswell. ” If there is something wrong with my BankCustomer.java orBCException.java please point it out and help me fix it.
Thanks again for helping.
Expert Answer
Answer to Instructions Using the BCException.java and the BankCustomer.java from the first part of the assignment you will impleme…
OR