1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 5 Due: Day 18 Problem 1. Currency Conversion (100%) For international business and travel, it is convenient to have a currency converter that can help you with financial management. In this problem set, we are going to implement a simple currency converter. The user interface for your program will look like the following figure: There is a CurrencyConverter(extends JFrame) that is the entire window. Within it there is a conPane(a Container) which has a conHolder(a plain JPanel). The conHolder contains a JTextField to enter the amount of currency, a JComboBox to choose the type of currency, a JLabel (“ = ”), another JTextField to display the result of conversion (use setEditable(false) to disable the edit option of this JTextField), another JComboBox just like the previous one, and a JButton to launch the conversion calculation. (You do not have to use the variable names listed here, but the variable type should still stay the same.) 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. Use the conversion rates below: 1 USD = 1.00909 EUR; 1 USD = 1.57852 CAD; 1 USD = 0.639059 GBP; 1 USD = 116.952 JPY; 1 USD = 48.6998 INR; 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. • Do NOT turn in electronic or hardcopies of compiled byte code (.class files). 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.