Currency Converter
£10-20 GBP
Betalt ved levering
A Currency Converter Application
The application you develop shall enable the user to easily convert money between British
Pound and Euro. The graphical user interface shall consist of a single window with a
menubar.
Approximately at the centre of the window should be a label that shows a number
(which may include a decimal point), e.g. 22.5. We call this the money label. Below
the label the window shall contain buttons for the digits 0 to 9, the decimal point \.",
a button for deleting the rightmost symbol of the label (digit or decimal point), and a
button for resetting the money label to 0. These buttons should be arranged similarly
to the number block of an ATM. So by clicking these buttons the user can change the
money label. Note that the money label should not take any input from the computer
keyboard. When the program starts, the money label shall be 0.
Additionally, above the money label, the window shall contain two buttons, one for
each currency, British Pound and Euro. At any time exactly one of these two buttons is
selected. At program start the British Pound button shall be selected. When the user
changes the selection to the other button, the amount in the money label is converted
from the previously selected currency into the newly selected currency.
The menubar comprises three menus: File, Currency and Help. The File menu has
only one option, quitting the application. The Currency menu lists the two currencies
British Pound and Euro. It provides an alternative means for choosing the currency.
The Help menu provides a Help entry, which shows on selection a dialogue box with
some basic use instructions, and an About entry, which shows on selection in a dialogue
box the name of the programmer.
The application window should have a reasonable layout, even when the user changes
its size. Enforce a reasonable minimal size of the window.
Implementation Requirements
The program shall consist of at least three classes:
1
A class ConverterGUI implements the graphical user interface. The object controls
the whole application.
A class FloatInput implements the content of the money label. Its methods
translate key inputs to a string and a
oating point number (e.g. the key inputs
7, . and 2 are translated into the string "7.2" and number 7.2). Note that this
class is independent of the GUI; it could be used also if the currency converter did
take input from a hardware keyboard.
A class Money implements the actual conversion between currencies.
At runtime there should exist one object of each class. The ConverterGUI object will
reference the other two objects. You may decide to use additional classes for other
purposes.
The constructor of the ConverterGUI class shall take a double parameter, which is
the exchange rate between the two currencies. That is, this parameter states the current
value of 1 GBP in Euro.
Ensure that every class and every method comes with a JavaDoc comment, which
brie
y describes its purpose and the purpose of arguments and return values (for meth-
ods).
For some states of the application some inputs make no sense. For example, if the
money label contains a number that has a decimal point, then a second decimal point
makes no sense. Also the money label should never have leading zeros, that is, something
like 0004.30. For easy usability, ensure that the user cannot select a button or menu
item that does not make sense for the current state of the application.
The application shall avoid any money amount with more than two digits after the
decimal point. First, that means that conversion always rounds the result to at most
two digits after the decimal point. Second, the user may enter any number into the
money label, but if the number has more than two digits after the decimal point, then
conversion should raise an exception. The user interface should catch this exception,
display an appropriate error message, and continue without performing the conversion
or otherwise changing the money label.
Projekt ID: #8227406