MIAMI DADE COLLEGE School of Engineering and Technology COP XXXXXXXXXXJava Programming Project 5 Due On: 4/22/2020 by 11:59 PM Expand Project 4 as follows: 1. Using the BankAccount class as a base...

1 answer below »
You need the base which is assignment 4 (I already did it) to continue with tha one that I'm sending.


MIAMI DADE COLLEGE School of Engineering and Technology COP 2800 - Java Programming Project 5 Due On: 4/22/2020 by 11:59 PM Expand Project 4 as follows: 1. Using the BankAccount class as a base class, write two derived classes called SavingsAccount and CheckingAccount. 2. Add a new private field name of type String to the BankAccount class. 3. Add accessor and mutator methods for the name field. 4. A SavingsAccount object, in addition to the attributes of a BankAccount object, should have a monthlyInterest variable and a method, which adds interest to the account. Assume you are adding the interest accumulated in a month. //monthlyInterest += (accountBalance * (annualInterestRate / 12)) //accountBalance += monthlyInterest public void addInterest() { //code goes here }; 5. The CheckingAccount class, in addition to the variables of a BankAccount class, should have an overdraftLimit variable (default to $50). Ensure that you override methods of the BankAccount class as necessary in both derived classes. 6. Create a Bank class, which contains an ArrayList of BankAccount objects called bankAccounts. BankAccounts in the array could be instances of the BankAccount class, the SavingsAccount class, or the CheckingAccount class. 7. Write an update method in the Bank class. It iterates through each account, updating it in the following ways: a. Savings accounts get interest added (via the addInterest method) b. Checking accounts get a letter sent (System.out.println) if they are in overdraft. (Hint: use instanceof operator) 8. The Bank class requires methods for openAccount and closeAccount. a. openAccount() should ask the user for: 1. his/her name (just first name, no last name) 2. what type of bank account (s)he wishes to open. Options are Regular Account (BankAccount object), Savings (SavingsAccount object) or Checking (CheckingAccount object). Create an object of the appropriate type and add it to bankAccounts. Display the account Id after this operation. 3. Initial Balance (minimum $100). Display a message if the user tries to open an account with less than $100 deposit (make sure account does not get created). b. closeAccount() should ask the user for his/her name and the account Id and then delete from bankAccounts the account that matches both the name and accountId. If they have a balance print a message indicating that a check with a balance will be mailed to them (indicate amount). 9. Test all your classes in the TestBankAccount class. Send all output to the console. Use a Scanner object to get user responses and System.out.println to print to the console. Additional Hints: a. Note that the balance of an account may only be modified through the deposit (double) and withdraw (double) methods. b. Changes to the original BankAccount class should be minimal. c. Make sure to test what you have done after each step. d. Make sure to include enough testing in TestBankAccount to cover all the functionality implemented. Submission guidelines: Send your code files (BankAccount.java, SavingsAccount.java, CheckingAccount.java, Bank.java and TestBankAccount.java) as attachments to my email [email protected], with the subject Java Project 5 Page 1 of 2
Answered Same DayApr 21, 2021

Answer To: MIAMI DADE COLLEGE School of Engineering and Technology COP XXXXXXXXXXJava Programming Project 5 Due...

Umakant answered on Apr 22 2021
146 Votes
Project5Code/Bank.java
Project5Code/Bank.java
import java.util.ArrayList;
import java.util.Scanner;
public class Bank {
    ArrayList bankAccounts = new ArrayList<>();
    public void openAccount() {
        Scanner scanner = new Scanner(System.in);
   System.out.print("Enter acount holder name:");
        String accountHolderName = scanner.nextLine();
        System.out.println("Type of account:\n1.Regular \n2.Saving \n3.Checking \n Please enter choice(1/2/3) ");
        int accountType = scanner.nextInt();
        if (accountType == 1) {
            BankAccount bankAccount = new BankAccount();
            bankAccount.setName(accountHolderName);
            bankAccounts.add(bankAccount);
        } else if (accountType == 2) {
            SavingsAccount savingsAccount = new SavingsAccount();
            savingsAccount.setName(accountHolderName);
            bankAccounts.add((BankAccount) savingsAccount);
        } else if (accountType == 3) {
            CheckingAccount checkingAccount = new CheckingAccount();
            checkingAccount.setName(accountHolderName);
            bankAccounts.add((BankAccount) checkingAccount);
        }
        System.out.println("Account created successfully. Your account Id: " + bankAccounts.get(0).getAccountId());
    }
    public void closeAccount() {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter account Holder Name:");
        String accountHolderName = scanner.nextLine();
        System.out.print("Enter account id:");
        int accountId = scanner.nextInt();
        System.out.println(bankAccounts.size());
        for (int i = 0; i < bankAccounts.size(); i++) {
            if (bankAccounts.get(i).getAccountId() == accountId
                    && bankAccounts.get(i).getName().equalsIgnoreCase(accountHolderName)) {
                double amount = bankAccounts.get(i).getAccountBalance();
 
                if(amount>0) {
                    System.out.println(amount +"$ amount will be mailed.");
                }else {
                    System.out.println("Account closed successfully.");
                }
            }
        }
    }

    public void update() {
        if(bankAccounts.get(0) instanceof SavingsAccount)
            new SavingsAccount().addInterest();
         if(bankAccounts.get(0) instanceof CheckingAccount)
             System.out.println("Overdraft limit");
    }

    public static void main(String[] args) {
        new Bank().openAccount();
    }
}
Project5Code/BankAccount.java
Project5Code/BankAccount.java
/*--------------------------------------------------------------------
-------------------------------------...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here