CMSC 206 (Data Structures)

Assignment#2

Due:  September 24, 2012 11:59:59pm

The goal of this assignment is to develop your ability to do object-oriented programming, focusing specifically on developing and using a basic class. 


Introduction

Over the next two assignments, you will write a program that allows a user to repeatedly create and manage credit card accounts.  In this assignment, we will focus on developing a basic class to represent the credit card.

When a new credit card account is opened, the credit company sets a credit limit for the user that specifies the maximum balance allowed on the account.  Unlike a debit card, the balance starts at $0.  The user can make purchases and charge them to the credit card, increasing the balance.  For example, if I charge two purchases of $100 and $50, my credit card balance would be $150.  Say that my credit limit is $500.  If I then tried to charge another $400 purchase to the card, the card would be declined since that would put the balance over my credit limit.  At the end of each month, the user must pay the entire balance on the card, or else the credit company charges the user interest on the balance.


Program Requirements
    1. Print out your name to System.out along with the string " CS 206 Assignment 2".
    2. Instantiate a new instance of the CreditAccount class
    3. Print out a description of the account, including account number, balance, credit limit and interest rate, by calling the toString() method on it.
    4. Charge $100 to the account (automatically printing out the corresponding status message of what was done to the account)
    5. Print out the current balance (which should be $100)
    6. Make a payment of $100 to the account (automatically printing out the corresponding status message of what was done to the account)
    7. Print out the current balance (which should be $0)
    8. Charge $100 to the account
    9. Print out the current balance (which should be $100)
    10. Make a payment of $50 to the account
    11. Print out the current balance (which should be $51.25, including the unpaid portion and the interest)
    12. Make a payment of $51.25 to the account
    13. Print out the current balance (which should be $0)
    14. Charge $-100 to the account, which should display an error message via an Exception
    15. Make a payment of $-100, which should display an error message via an Exception
    16. Print out the current balance (which should still be $0)


Implementation Hints



Submitting the Assignment

Be certain that your CreditAccount.java file contains proper header comments that include your name.

Place your CreditAccount.java file and compiled CreditAccount.class file into a directory entitled LastnameFirstname-Assignment2.  Compress this folder as a zip or tar file, and submit it via Dropbox, as detailed in the assignment submission instructions.