Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Checking and Savings accounts may not be the only types of accounts. Moreover, different account types may have different rules for withdrawal, interest calculation, etc.

  1. Checking and Savings accounts may not be the only types of accounts. Moreover, different account types may have different rules for withdrawal, interest calculation, etc. To support this, do the following:

    1. Create an abstraction (i.e., an interface or abstract class with no concrete implementation) to represent a generic bank account.

      1. All bank accounts have an account number, account holder(s) and a current balance. The abstraction must have functions to retrieve all these pieces of information.

      2. The abstraction must contain a function to add a new account holder.

      3. The abstraction must contain functions to support deposit and withdraw actions. The withdraw function must be capable of throwing an exception if there is insufficient account balance.

      4. The abstraction must contain a function to calculate interest using the current account balance and an interest rate and add that interest to the existing account balance. [Note: you can assume that some other entity is responsible for calling this function at the desired frequency, e.g., daily, monthly, etc.]

    2. Create a class with a function that automatically generates a unique bank account number. [Hint: the simplest approach is to use a static or class level attribute and corresponding function].

    3. Create a concrete implementation of the abstraction created in Step a to represent a Checking account. Assume these rules:

      1. It must be possible to create a Checking account with or without an initial deposit. The account number must be automatically generated using the generator from Step b.

      2. Any withdrawal that does not reduce the account balance to less than 0 is considered valid. If an invalid withdrawal occurs, an exception must be thrown indicating that the balance is insufficient to perform the withdrawal.

      3. A Checking account has a flat interest rate of 0.01%.

    4. Create a concrete implementation of the abstraction created in Step a to represent a Savings account. Assume the following rules:

      1. A Savings account requires a minimum initial deposit of $100. The account number must be automatically generated using the generator from Step b.

      2. A Savings account must maintain a minimum balance of $100 at all times. Any withdrawal that would make the balance go below this minimum amount is considered invalid. If an invalid withdrawal occurs, an exception must be thrown indicating that the balance is insufficient to perform the withdrawal.

      3. A Savings account has the following interest rates:

        1. < $2,000 balance: 0.01%

        2. >= $2,000 & < $12,000 balance: 0.05%

        3. >= $12,000 balance: 0.1%

    5. Create a bank account demo class. In this class, write a driver/main function to demonstrate your implementation. In this main function, do the following:

      1. Create a Checking account for Julio Perez with no initial deposit. Once the account is created, display the (generated) account number for the users benefit.

      2. Perform the following operations on Julios Checking account - after each operation below, display the current balance in the account:

        1. Deposit $1500 into the account.

        2. Withdraw $150 from the account.

        3. Perform interest accumulation (i.e., call the function that calculates and adds interest).

        4. Withdraw $750 from the account.

        5. Perform interest accumulation.

      3. Create a Savings account for Sasha Ivanov with an initial deposit of $600. Once the account is created, display the (generated) account number for the users benefit.

      4. Perform the following operations on Sashas Savings account - after each operation below, display the current balance in the account:

        1. Perform interest accumulation.

        2. Deposit $150 into the account.

        3. Perform interest accumulation.

        4. Withdraw $600 from the account.

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

More Books

Students also viewed these Databases questions