icon

UseTopicwritingscode to get 5% OFF on your first order!

Project 9-2 Account Balance Calculator

Project 9-2: Account Balance Calculator
Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account.

Console
Welcome to the Account application

Starting Balances

Checking: $1,000.00

Savings:  $1,000.00

Enter the transactions for the month

Withdrawal or deposit? (w/d): w

Checking or savings? (c/s): c

Amount?: 500

Continue? (y/n): y

Withdrawal or deposit? (w/d): d

Checking or savings? (c/s): s

Amount?: 200

Continue? (y/n): n

Monthly Payments and Fees

Checking fee:              $1.00

Savings interest payment:  $12.00

Final Balances

Checking: $499.00

Savings:  $1,212.00

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:

void deposit(double amount)

The Withdrawable interface should include this method:

void withdraw(double amount)

And the Balanceable interface should include these methods:

double getBalance()
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 AccountBalanceApp that uses these objects to process and display deposits and withdrawals.

Use the Console class presented in chapter 7 or an enhanced version of it to get and validate the user’s entries. Don’t allow the user to withdraw more than the current balance of an account.

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes