121k views
1 vote
Look at the Account class Account.java (GIVEN AT THE BOTTOM) Download Account.java and write a main method in a different class to briefly experiment with some instances of the Account class.

Using the Account class as a base class, write two derived classes called SavingsAccount and CurrentAccount. A SavingsAccount object, in addition to the attributes of an Account object, should have an interest variable and a method which adds interest to the account. A CurrentAccount object, in addition to the attributes of an Account object, should have an overdraft limit variable. Ensure that you have overridden methods of the Account class as necessary in both derived classes.
Now create a Bank class, an object of which contains an ArrayList of Account objects. Accounts in the ArrayList could be instances of the Account class, the SavingsAccount class, or the CurrentAccount class. Create some test accounts (some of each type).
Write an update method in the bank class. It iterates through each account, updating it in the following ways: Savings accounts get interest added (via the method you already wrote); CurrentAccounts get a letter sent if they are in overdraft.
The Bank class requires methods for opening and closing accounts, and for paying a dividend into each account.

1 Answer

4 votes

Final answer:

Banks offer checking and savings accounts to facilitate transactions and encourage saving with interest accumulation, respectively. In programming, these account types can be represented with derived classes inheriting from a base Account class. A Bank class would handle an array of these accounts, each with specific functionality like accruing interest or managing overdrafts.

Step-by-step explanation:

Banks provide different types of accounts to suit the various financial needs of individuals and businesses. A checking account is essential for facilitating day-to-day transactions, allowing for easy access to funds through checks or a debit card. In contrast, savings accounts are designed to accumulate interest over time, incentivizing saving, but may require a trip to the bank or ATM for withdrawals.

Over time, the distinction between savings and checking accounts has become less clear as banks offer hybrid accounts, which provide the features of both types of accounts to different degrees.

The concept of SavingsAccount and CurrentAccount in the context of object-oriented programming can be represented with derived classes inheriting from a base Account class. These classes encapsulate the specific behaviors of each account type, such as accruing interest in SavingsAccount or managing the overdraft limit in CurrentAccount.

A Bank class may manage multiple accounts of these different types through an ArrayList of Account objects. This class would provide functionality to open and close accounts, pay dividends, and update accounts, including adding interest or notifying customers of an overdraft.

User Frans Bouma
by
8.1k points