CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades | Students

Assignment #7

Calculate the monthly balances of two bank accounts

Due Date: Monday of Week 4
25 points

This project uses three interfaces that define methods for accounts that can accept deposits, accept withdrawals, or get and set balances. These interfaces are implemented by an account class, which is then inherited by a checking account class and a savings account class. It also uses another class that provides for posting transactions to either type of account. To do that, the methods of this class accept an interface type as a parameter. This project is challenging because it uses so many interfaces and classes.

Console

Operation

  • The application begins by displaying the starting balances for a checking and savings account.
  • The application prompts the user to enter the information for a transaction, including whether a withdrawal or deposit is to be made, whether the transaction will be posted to the checking or savings account, and the amount of the transaction.
  • When the user finishes entering deposits and withdrawals, the application displays the fees and payments for the month followed by the final balances for the month.

Specifications

  • Create interfaces named Depositable, Withdrawable, and Balanceable that specify the methods that can be used to work with accounts. The Depositable interface should include this method:
  • public void deposit(double amount)
    The Withdrawable interface should include this method:
    public void withdraw(double amount)
    And the Depositable interface should include these methods:
    public double getBalance()
    public void setBalance(double amount)
     	
  • Create a class named Account that implements all three of these interfaces. This class should include an instance variable for the balance.
  • Create a class named CheckingAccount that inherits the Account class. This class should include an instance variable for the monthly fee that's initialized to the value that's passed to the constructor. This class should also include methods that subtract the monthly fee from the account balance and return the monthly fee.
  • Create a class named SavingsAccount that inherits the Account class. This class should include instance variables for the monthly interest rate and the monthly interest payment. The monthly interest rate should be initialized to the value that's passed to the constructor. The monthly interest payment should be calculated by a method that applies the payment to the account balance. This class should also include a method that returns the monthly interest payment.
  • Create a class named Transactions that contains two static methods for depositing and withdrawing funds from either type of account:
  • Create a class named AccountApp that prompts the user for a transaction, posts the transaction, and displays the information shown in the console output. Create the necessary objects for each transaction, and post the transaction using the appropriate method of the Transactions class.
  • Use the Validator class or a variation of it to validate the user's entries. This validation code should not allow the user to withdraw more than the current account balance.
Include in your program the following comments:
  • Name of program
  • Programmer's name
  • Current Date
  • Computer system and compiler you are using
  • Brief description of the program

Compile and run the Java program.

Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.

When you are ready, upload the java program and the gif file by clicking the link below:

Upload Assignment

I cannot grade if I don't get the files and receive your email.