Overview
For this homework you will implement an interest calculator. A video of the
calculator you need to implement can be found at Video.
Notice that there are no public/release/secret tests associated with this
project. In addition, you do not need to provide any student tests.
Objectives
This project is designed to help you develop your skills at defining inner
classes and simple GUIs.
Grading
- (30%) GUI
- (5%) principal text field
- (5%) rate text field
- (5%) years text field
- (5%) simple interest button
- (5%) compound interest button
- (5%) labels (Principal:, Rate(Percentage):, Years:)
- (15%) Correct computation of simple interest
- (15%) Correct computation of compound interest
- (20%) Non-Anonymous inner class for simple interest button
- (20%) Anonymous inner class for compound interest button
Clarifications
Any clarifications or corrections associated with this project will be
available at Clarifications.
Code Distribution
For this project we are not providing any code (we just defined a package).
We are providing an empty code distribution (available by checking out the
project named InterestCalculator) so you can submit your
project as usual. Feel free to add any classes/packages you understand you
need. To simplify the grading process, make sure you have in the
calculator package a class named
InterestGUI.java. This class must have a main method that
allow us to execute the calculator program.
Specifications
Interest Functions
You need to implement a GUI for a calculator that computes simple and
compound interest. The formula to compute simple interest amount is:
simple interest amount = principal + (principal * (rate/100) *
years)
The formula to compute compound interest amount is:
Compound Interest Amount = principal * (1 +
rate/100)Years
Notice that you do not need to add the principal in this case.
Displaying Currency
To display currency you can use the NumberFormat class (part of java.text)
as follows:
String formattedValue =
NumberFormat.getCurrencyInstance().format(value);
where value represents the numeric value to format.
Requirements
- Your GUI should resemble the GUI available in the video, but it does not
have to be exactly the same.
- Keep the Model-View-Control model in mind when writing your code. Feel free to add
any classes you understand you need.
- You may only use inner classes to define event listeners.
- One of your listener objects must be implemented using an anonymous inner
class.
- One of your listener objects must be implemented using a non-anonymous
inner class.
- You must attempt to submit your project immediately after checking out
the project (even if you have not implemented any methods). This will allow
you to verify that the submission process is working as expected.
- You should submit your project often. This will keep versions of your
project in the submit server that are easy to retrieve (you can also get
previous versions from your CVS repository). If your computer crashes or
you experience any other problem you will have a permanent backup in the
submit server.
- No student tests are required for this project.
- Style
- Good variable names.
- You must avoid code duplication by calling appropriate methods
(rather than cutting and pasting code). You may define your own private
utility methods to perform often repeated tasks.
- Style as defined by the Eclipse Format Element option (Source →
Format → Format Element) or as specified in Code
Conventions for the JavaTM Programming Language (focus on the
following sections: Indentation, Declarations, Statements, White Space,
and Naming Conventions).
- Although you should avoid source lines exceeding 80 characters, you
will not be penalize if they are present in your code.