S428 Advanced Application Development
Assignment 1
Due Friday, Jan 28 by 11:59PM.
- Write a Java program that performs a currency conversion using a built-in
conversion table. You will find conversion tables from many different sites,
but the one that you should use for this assignment is available from http://www.xe.com/ict/.
If you go to this web site, select the base currency as US Dollars, select
"most recent rate" for the conversion date and generate the conversion table
in "fixed width format", it will create a table in plain text that looks like
the following:
Currency Unit USD per Unit Units per USD
==================================== ================= =================
DZD Algeria Dinars 0.0139694 71.5850
USD United States Dollars 1.00000 1.00000
ARS Argentina Pesos 0.340716 2.93500
AUD Australia Dollars 0.757445 1.32023
EUR Euro 1.30411 0.766809
- The first part of your task would be to somehow incorporate this data into
your program. One way to do this would be to use Microsoft Excel to import
the data (generating a HTML table would make it easy to bring the data into
Excel - you can just copy and paste), and then creating a formula to generate
the Java array declaration for the array(s) that you need to store this information.
Another method would be to store the information in a file, and then use your
program to read the information into the arrays. How you actually do it is
up to you. This part of the problem can be treated as collaborative, although
everyone has to convert the data individually. You can post a description
of how you do it on the forums, and if you are having problems with any specific
thing you try, ask the opinion from the class on your method.
- Once you have the table in your code, the next step is to use this table
for the purpose of interactive conversion. There are two types of conversion
- for the sake of simplicity, lets say we call the ToDollars and FromDollars.
ToDollar conversion works like this: 100 Euros ToDollar gives 130.41 dollars,
and 100 FromDollar to Euro gives you 76.68 Euros.
- You will need to interactively ask the user for an amount and the target
currency, and generate the result of conversion both ways. You will need to
ensure that your program is somewhat intelligent to find all the currencies
that match the currency asked for. So if someone says, Dollar, it should match
US Dollars, Australia Dollars, and so on. Also, you should allow people to
search on partial matches, so someone can search for Aus as the target, and
you should be able to find both Austria as well as Australia. The more intelligent
you are the better, but the baseline of course is a complete match for the
currency code (e.g., USD) or the currency name (e.g., United States Dollars).
- Name your java program
Convert.java
- Remember that you should only make ONE instance of the Input class!
Also, make sure you take the inputs in the same order as shown in the sample
output. If you change the order of inputs, your submission will not work properly!
Feel free to change the prompts and the text that is printed by your program though.
- Sample output. The following is a sample of how your program would look
like. User inputs are shown in red.
Welcome to my fancy(not!) conversion program!
Please enter the amount you want to convert,
And the target currency to compute.
Enter a negative amount to quit.
---
Enter the amount: 100
Enter the target currency: usd
ToDollar: USD 100.0 (United States Dollars) yields $100.0
FromDollar: $100.0 yields USD 100.0 (United States Dollars)
---
Enter the amount: 150
Enter the target currency: mala
ToDollar: MYR 150.0 (Malaysia Ringgits) yields $39.47
FromDollar: $150.0 yields MYR 569.99 (Malaysia Ringgits)
---
Enter the amount: 200
Enter the target currency: euro
ToDollar: EUR 200.0 (Euro) yields $260.82
FromDollar: $200.0 yields EUR 153.36 (Euro)
---
Enter the amount: 50.35
Enter the target currency: rupee
ToDollar: INR 50.35 (India Rupees) yields $1.15
FromDollar: $50.35 yields INR 2197.78 (India Rupees)
---
ToDollar: PKR 50.35 (Pakistan Rupees) yields $.85
FromDollar: $50.35 yields PKR 2992.05 (Pakistan Rupees)
---
Enter the amount: 75
Enter the target currency: help
Sorry - no information about currency help
---
Enter the amount: -1
Bye-bye!
Some notes and hints
Submission method You will need to submit your assignment
using the online submission system. To submit, use the following
steps:
- Point your web browser to The S428 Handin Page If your
browser asks if you want to display the non-secure items, say Yes (the only
non-secure thing in that page is the s428 icon, so don't worry :) ).
- Type in your email address (including the @indiana.edu part) and
your student ID without any dashes or spaces in the appropriate
boxes.
- Upload the two files for submission in the two fields
provided by clicking on the Browse button and selecting the
appropriate file. If you are using steel to write your code, you
will need to download the java files from steel to the machine
where you are using the web browser. Submit only the .java
files. No class files. Follow the namig convention as stated in
the assignment.
- Click on "Submit Assignment", and wait until you get the
confirmation page. This may take a couple of minutes - do not
click multiple times. The system will display a confirmation
page.
- You are not done yet! Check your email for a confirmation
email from the submission system. It may take upto 5 minutes for
you to receive the confirmation email. Make sure you read
and understand the email, including the information that it
gives you. Do not assume that your assignment submission was
successful until you receive an email with no error
message. Look in particular for the file "CompilationErrors". If
it says "Empty file!" for this, you are fine. If any compilation
errors are shown, you will need to fix them. Your assignment
will be severly penalized if you have compilation errors.
- You may submit as many times as you would like - future
submissions will overwrite any file submitted with the same
name. If you change only one file, you can submit only that
file. The confirmation message will include all files submitted
so far. Keep a copy of the confirmation message. This will be
proof that your submission was successful in the case of a
system glitch later.