Write a program CurrencyConverter.java (in a package named a02) that takes currency amounts in Euros (EUR), US Dollars (USD) and Japanese Yen (JPY) as command line arguments and converts them to canadian dollars (CAD).
The correct format for the command line arguments will be at least one digit (possibly more) followed by a '.' folowed by exactly 2 digits followed by a 3 character currency code (ignoring upper or lower case).
Some examples of valid arguments are:
0.34USD
30.00eur
55768.34jPY
Some examples of invalid arguments are:
.34USD
30EUR
5768.931JPY
Your program will need to check if the arguments are valid and it should not crash if they are not valid.
Hints:
The min length of a valid input is 7
A valid input must end with one of the 3 character codes
The 3 characters before that must be '.' then two digits
All the characters before that, no matter how many there are need to be digits
The program should have 2 modes of operation:
1) If no command line arguments are given the program should display the normal
information header as well as instructions for the user on the correct usage of
the program (how command line arguments should be formatted to be valid).
The program should then pause before ending.
Example with no command line parameters:
Assignment##
Lastname, Firstname
A########
Description of the program
Including instructions for use
Press enter to end...
2) If one or more command line argument(s) is provided the program will not display the information header and will output the converted amounts one per line. If any of the inputs are invalid then the corresponding line will display an error message but the program will continue with converting the next argument until all have been converted. The program should then pause before ending.
Example with command line arguments: 12.50EUR 125.00USD 13EUR 15.67USD 50000.00JPY 1.00JPY
€12.50 EUR is $19.00 CAD.
$125.00 USD is $161.25 CAD.
Error: invalid input 13EUR.
$15.67 USD is $20.21 CAD.
¥50000.00 JPY is $550.00 CAD.
¥1.00 JPY is $0.01 CAD.
Press enter to end...
Notice the format of the output, both the input amount and the converted amount are displayed with the correct currency symbol and exactly 2 places after the decimal point. Also the values are rounded correctly to those 2 digits after the decimal point (printf will do this rounding for you!).
The program should use the following exchange rates:
1 EUR is 1.52 CAD
1 USD is 1.29 CAD
1 JPY is 0.011 CAD
For this assignment you should use several methods (with Javadoc comments) rather than have all the code in the main method. For example a method that checks if a parameter is valid, a method that converts the currency, a method that outputs the results in the correct format, etc.