Starting from:
$35

$29

PROGRAM #13 Solution

Outcomes:

    • Write programs that use object oriented programming concepts.
    • Write programs that use objects.
    • Write programs that use ArrayList.
    • Write applications using object oriented programming concepts.

Assignment:
    1. Download BankAccount.java and Program13.java into a new folder called Program13. 
    2. Implement the menu driven Banking Application by completing the “STUBS” provided in Program13.java file using the BankAccount class provided in the folder. See the sample run below for the format you should match in your application.
    3. Your solution should include completing the following methods which should be called when the user selects the corresponding menu options:

public static void createAccount(ArrayList<BankAccount> list) {
    //creates an account
}
public static void display(ArrayList<BankAccount> list) {
    //displays the specific account details
}
public static void displayAll(ArrayList<BankAccount> list){
    // displays all the account details
}
public static void withdraw(ArrayList<BankAccount> list) {
     // withdraws money from the specific object
}
public static void deposit(ArrayList<BankAccount> list) {
    // deposits money into the specific object
}
public static void removeAccount(ArrayList<BankAccount> list){
    // removes the specific account details
}

    4. Once your program is working well, use a loop to implement error checking, so that the user cannot enter illegal inputs and make sure that it terminates only on user’s choice 6. 

Sample run: (Text shown in red are user’s inputs)
***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  5

No Accounts Created yet!!

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  1

**Create New Account**
Enter name:  John
Starting balance: 10000
Account Created!!

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice: 2

Enter Your name: John
**Account Details**
Name: John   Balance: 10000.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  3

Bank Account Details
Name: John   Balance: 10000.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  4

**Transaction - Deposit**
Enter Your Name:  John
Enter amount to deposit:  1000
Name: John    Balance: 11000.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  5

**Transaction - Withdraw**
Enter Your Name:  Johny
Name: Johny does not exist

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  1

**Create New Account**
Enter name: Mathew
Starting balance:  2000
Account Created!!

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  3

Bank Account Details
Name: John   Balance: 11000.0
Name: Mathew   Balance: 2000.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  5

**Transaction - Withdraw**
Enter Your Name: Mathew
Enter amount to withdraw:  100
Name: Mathew   Balance: 1900.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  3

Bank Account Details
Name: John   Balance: 11000.0
Name: Mathew   Balance: 1900.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  6

Enter Your Name:  John
Account Deleted!!

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  3

Bank Account Details
Name: Mathew   Balance: 1900.0

***  Menu  ***
1. Create Account
2. Display
3. Display All
4. Deposit
5. Withdraw
6. Remove Account
7. Exit

Enter your choice:  7

Thanks for banking with us!!

>

Advice:
    1. Your application uses an ArrayList called list that is capable of storing the BankAccount objects for any number of customers.
    2. The list.size() method can be used in the loop to process(print/check for a specific account) all the BankAccount objects stored in the list.
    3. At first, write the program without worrying about the user entering invalid numbers. Once the program is working correctly with valid numbers, then add the loop for handling bad numbers.

More products