Question: Java Coding Only. Create a currency convertor program. It will store conversion rates between a currency and the US$ for a month. The program flow
Java Coding Only.
Create a currency convertor program. It will store conversion rates between a currency and the US$ for a month. The program flow is as follows:
Part Get user input for the historical data.
Historical data will be the currency, day of month and conversion rate. Keep getting input until a null or space is entered for the currency.
Assume currencies max will be entered.
Store data in a dimensional array. I recommend creating a rows by columns matrix. Rows are day of month, columns are currency. Each cell will store the rate that was input for that CurrencyDay of Month pair.
Once unique currencies are entered, do not accept any more unique currencies.
Part Get user input to lookup rates
User will input a currency, day of month and an amount.
You will check if a rate exists for that currency & day. If it does you will multiply the amount by
the rate and output the US$ equivalent. If the currencydate pair doesn't exist or there's no rate
for it output "Data Not Available"
Keep requesting input until user enters null or space for currency and then terminate the
program
Example program output:
Enter Historical Data Currency Day of Month, Rate: EUR,
Enter Historical Data Currency Day of Month, Rate: EUR,
Enter Historical Data Currency Day of Month, Rate: JPY
Enter Historical Data Currency Day of Month, Rate: GBP
Enter Historical Data Currency Day of Month, Rate: user enters null
Enter Conversion LookupCurrency Day of Month, Amount: EUR,
EUR US$
Enter Conversion LookupCurrency Day of Month, Amount: GBP
Data Not Available
Enter Conversion LookupCurrency Day of Month, Amount: GBP
GBP US$
Enter Conversion LookupCurrency Day of Month, Amount: user enters null
program terminates
You can assume that days will be but currencies and rates are dependent on user input. Do not
"hard code" the data I have shown here. It's just to help you design your program.
PseudoCode Programming Tips Currency Convertor Project
Load Historical Data
Define a dimensional array named RateMatrix
double RateMatrixnew double;
You will store the days of month and rates in the dimensional array
Columns
Day of the month
currency #
currency #
currency #
Rows
Theres thats the most days per month you can have
Define a single dimension array named ccyMap
String ccyMap new String
You will store each currency string in here, up to You use this array to map to
the correct column in RateMatrix.
ccyMap will be the currency that is column in Rate Matrix.
ccyMap will be the currency that is column in Rate Matrix.
ccyMap will be the currency that is column in Rate Matrix.
Pseudo Code
Get inputStr Currency Day of Month, Rate from user
While input is not null
Split inputStr into inputAra
ccy inputAra
dayOfMonth convert inputAra to double
rate convert inputAra to double
if ccy is already in ccyMap
get position in ccyMap
else
if number of currencies
error message Too May Currencies
break
else
add ccy to ccyMap
get position in ccyMap
end if
end if
Find day of month in RateMatix
row
dayFound false
While RateMatrixrow dayOfMonth && dayFound
If RateMatrixrow dayOfMonth
row
else
dayFound true
end if
end while
col position in ccyMap
RateMatrixrowcol rate
End While
Get User Lookup Data
Ask user to input lookup Currency, Day of Month & Amount. Exit loop when currency is
null.
Check for valid input
Day is between and
Currency is found in ccyMap
If invalid data is entered
Display error message
Continue loop
Determine rowcolumn for this CurrencyDate Pair
Get value in cell of RateMatrixrowcolumn
If cell RateMatrixrowcolumn is not empty
Multiply rate by amount and display conversion amount
Else
Display Data not Available
Program Output:
Enter Currency Day of Month, Rate: EUR,
Enter Currency Day of Month, Rate: EUR,
Enter Currency Day of Month, Rate: GBP
Enter Currency Day of Month, Rate: JPY
Enter Currency Day of Month, Rate: CHF
Currencies max. Please try again.
Enter Currency Day of Month, Rate: EUR,
Enter Currency Day of Month, Rate: EUR,
Day of month must be between & Please try again.
Enter Currency Day of Month, Rate: GBP
Enter Currency Day of Month, Rate: JPY
Enter Currency Day of Month, Rate: null
Enter Lookup Currency Day of Month, Amount: EUR,
EUR USD
Enter Lookup Currency Day of Month, Amount: EUR,
Data Not Available
Enter Lookup Currency Day of Month, Amount: CHF
Currency Not Available
Enter Lookup Currency Day of Month, Amount: GBP
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
