Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello my dear Colud you please help me in this question please *Please when you solve use do while loop* __________________ *Account* package sa.edu.yuc; import

Hello my dear Colud you please help me in this question please

*Please when you solve use do while loop*

__________________

*Account*

package sa.edu.yuc; import java.util.Scanner; public class Account implements Comparable{ private int id; private String name; private double balance; public Account(int id, String name, double balance) { this.id = id; this.name = name; this.balance = balance; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public double getBalance() { return balance; } public void setBalance(double balance) { this.balance = balance; } @Override public String toString() { return "Account [id=" + id + ", name=" + name + ", balance=" + balance + "]"; } public boolean equals(Object other) { return this.id == ((Account)other).getId(); } @Override public int compareTo(Account o) { // TODO Auto-generated method stub return 0; } public static Account getAccount() { Scanner input = new Scanner(System.in); System.out.println(); System.out.println("Enter Account Information :: "); System.out.print("Id: "); int id = input.nextInt(); input.nextLine(); System.out.print("Name: "); String name = input.nextLine(); System.out.print("Balance: "); double balance = input.nextDouble(); System.out.println(); return new Account(id, name, balance); } }

________________________

*ArrayDuplicateException*

package sa.edu.yuc;

public class ArrayDuplicateException extends Exception { public ArrayDuplicateException(String message) { super(message); } }

_______________________

*ArrayEmptyException*

package sa.edu.yuc; public class ArrayEmptyException extends Exception { public ArrayEmptyException(String message){ super(message); } }

________________________

*ArrayFullException*

package sa.edu.yuc; public class ArrayFullException extends Exception{ public ArrayFullException(String message) { super(message); } } ________

*Bank*

package sa.edu.yuc; public class Bank { public boolean addAccount(Account account) throws ArrayFullException, ArrayDuplicateException { // TODO Auto-generated method stub return false; } public Account findAccount(int id) throws ArrayEmptyException { // TODO Auto-generated method stub return null; } public boolean deleteAccount(int id)throws ArrayEmptyException { // TODO Auto-generated method stub return false; } public void showAll() { // TODO Auto-generated method stub } }

__________________

*BankTest*

package sa.edu.yuc; import java.util.Scanner; public class BankTest { public static void main(String[] args) { Bank bank = new Bank(); Scanner input = new Scanner(System.in); int option; do{ menu(); System.out.print("Enter Option(1..5) > "); option = input.nextInt(); switch (option) { case 1: // TODO Auto-generated method stub break; case 2: // TODO Auto-generated method stub break; case 3: // TODO Auto-generated method stub break; case 4: // TODO Auto-generated method stub break; case 5: System.out.println("Thank you for using bank application !!!"); break; default: System.out.println("Invalid option Plz enter(1..5)!!!"); } }while(option != 5); } private static void menu() { System.out.println("Welcome to MyBank"); System.out.println("Press 1 to add an account"); System.out.println("Press 2 to find an account"); System.out.println("Press 3 to delete an account"); System.out.println("Press 4 to list all accounts"); System.out.println("Press 5 to exit"); } }

_____________

*MyArray*

package sa.edu.yuc; public interface MyArray { public boolean isEmpty(); public boolean isFull(); public boolean add(int value) throws ArrayFullException, ArrayDuplicateException; public boolean remove(int value) throws ArrayEmptyException; public int find(int value) throws ArrayEmptyException; public int get(int index); }

_______________________

*MyArrayImpl*

package sa.edu.yuc; public interface MyArray { public boolean isEmpty(); public boolean isFull(); public boolean add(int value) throws ArrayFullException, ArrayDuplicateException; public boolean remove(int value) throws ArrayEmptyException; public int find(int value) throws ArrayEmptyException; public int get(int index); }

image text in transcribed

image text in transcribed

image text in transcribed

Q.1: Write a program which will allow the user following functionality. Add a new account Find an account Delete an account List all accounts User could be shown following menu. Press 5 to quit 1 - To add a new account 2 - Find an account by account Id 3 - Delete an account by account Id 4 - List all accounts On selecting 1, user should be asked for all the attribute values of the account On selecting 2, user should be asked for the account Id. Search should be performed accordingly. On selecting 3, user should be asked for the account ld. Delete should be performed accordingly. On selecting 4, user should be shown all the accounts with the details. Output: Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 1 Enter Account Information :: Id: 100 Name: rrr Balance: 5689 Done Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 1 Enter Account Information :: Id: 89 Name : uuu Balance: 9089 Done Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 1 Enter Account Information :: Id: 150 Name: ddd Balance: 7654 Done Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 1 Enter Account Information :: Id: 95 Name: ggg Balance: 5643 Done Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 4 Account [id=89, name=uuu, balance=9089.0] Account [id=95, name=ggg, balance=5643.0] Account [id=100, name=rrr, balance=5689.0] Account [id=150, name=ddd, balance=7654.01 Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 2 Enter id to search = 95 Account [id=95, name=ggg, balance=5643.0] Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 2 Enter id to search = 900 Invalid Account ID Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 3 Enter id to search = 100 Account is deleted Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 4 Account [id=89, name=uuu, balance=9089.0] Account [id=95, name=ggg, balance=5643.0] Account [id=150, name=ddd, balance=7654.01 Welcome to MyBank Press 1 to add an account Press 2 to find an account Press 3 to delete an account Press 4 to list all accounts Press 5 to exit Enter Option (1..5) > 5 Thank you for using bank application

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

Step: 3

blur-text-image

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

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago