Professional Documents
Culture Documents
The user interface for your program will look like the following figure:
Step 1:
First create a CurrencyConverter class and remember to include the following import
statements.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
Please make sure that you know the reasons that these import statements are needed.
Declare the necessary variables that give you the different components of the window.
You could use a String array to keep the different currency types.
In the constructor, instantiate all the variables and set the window size with height 70
pixels and width 700 pixels. From the description of the user interface, you should know
what component to add to what component. Have the texts in both JTextField aligned
right.
In the main() function, create a CurrencyConverter object. Set the default close
operation to exit when the x is clicked on the window. Remember to use the show() or
the setVisible(true) function to display the window.
By now, you should be able to execute the main() program and see something similar to
the user interface on the previous page.
Step 2:
Now add a ActionListener to the JButton. It needs to be able to do the currency
conversion and then display the result. (Note: The default currency should be the
currency type that is displayed when the window just loaded up. In our example, the
default currency is US dollars.) In this step, you might want to add more data fields that
will help you solve the problem. You are also welcomed to create other classes that will
help you to do the calculation.
Since in most currencies the smallest unit is one cent, the output of the conversion should
only have up to 2 decimals. For example for 10 USD conversion to CAD should be
displayed as 15.79 CAD and not 15.7852 CAD.
Turnin
Turnin Requirements
Hardcopy and electronic copy of ALL source code (all .java files). Remember to
comment your code; points will be taken off for insufficient comments.
Place a comment with your name, username, section, TA's name, assignment number,
and list of people with whom you have discussed the problem set on ALL files you
submit.
Electronic Turnin
Use SecureFX (or another secure ftp or secure shell program) to upload your problem set
to your 1.00 homework locker.
Detailed instructions of how to upload are on the course website.
Since your problem set is due at the beginning of lecture, your uploaded problem should
have a timestamp of no later than morning on the due date.
Penalties
Missing Hardcopy: -10% off problem score if missing hardcopy.
Missing Electronic Copy: -30% off problem score if missing electronic copy.
Late Turnin: -30% off problem score if 1 day late. More than 1 day late = NO
CREDIT.
If your problem set is late, or if a professor has granted you an extension in advance, do
not submit a printed copy of your problem set.