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 1)Get user input for the historical data.
Historical data will be the currency, day of month (1-31) and conversion rate. Keep getting input until a null or space is entered for the currency.
Assume 3 currencies max will be entered.
Store data in a 2-dimensional array. I recommend creating a 33(rows) by 5(columns) matrix. Rows are day of month, columns are currency. Each cell will store the rate that was input for that Currency/Day of Month pair.
Once 3 unique currencies are entered, do not accept any more unique currencies.
(Part 2) 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 currency/date 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, 1,1.11
Enter Historical Data (Currency, Day of Month, Rate): EUR, 2,1.10
Enter Historical Data (Currency, Day of Month, Rate): JPY,1,.0092
.....
Enter Historical Data (Currency, Day of Month, Rate): GBP,31,1.24
Enter Historical Data (Currency, Day of Month, Rate): [user enters null]
Enter Conversion Lookup(Currency, Day of Month, Amount): EUR, 2,1000.00
1000.00 EUR =1110.00 US$
Enter Conversion Lookup(Currency, Day of Month, Amount): GBP,7,2000.00
Data Not Available
Enter Conversion Lookup(Currency, Day of Month, Amount): GBP,5,2000.00
2000.00 GBP =2500.00 US$
Enter Conversion Lookup(Currency, Day of Month, Amount): [user enters null]
program terminates
You can assume that days will be 1-31 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
1. Load Historical Data
Define a 2 dimensional array named RateMatrix
double RateMatrix[][]=new double[32][4];
You will store the days of month and rates in the 2 dimensional array
Columns
0= Day of the month
1= currency #1
2= currency #2
3= currency #3
Rows
Theres 31 thats the most days per month you can have
Define a single dimension array named ccyMap
String ccyMap[]= new String [3]
You will store each currency string in here, up to 3. You use this array to map to
the correct column in RateMatrix.
ccyMap[0] will be the currency that is column 1 in Rate Matrix.
ccyMap[1] will be the currency that is column 2 in Rate Matrix.
ccyMap[2] will be the currency that is column 3 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[0]
dayOfMonth = convert inputAra[1] to double
rate = convert inputAra[2] to double
if (ccy is already in ccyMap)
get position in ccyMap
else
if number of currencies >3
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 =0
dayFound = false
While (RateMatrix[row,0]!= dayOfMonth && !dayFound
If RateMatrix[row,0]!= dayOfMonth
row++
else
dayFound = true
end if
end while
col = position in ccyMap
RateMatrix[row,col]= rate
End While
2. 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 1 and 31
Currency is found in ccyMap
If invalid data is entered
Display error message
Continue loop
Determine row/column for this Currency/Date Pair
Get value in cell of RateMatrix(row,column)
If cell RateMatrix(row,column) 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, 1,1.10
Enter (Currency, Day of Month, Rate): EUR, 2,1.14
Enter (Currency, Day of Month, Rate): GBP,9,1.25
Enter (Currency, Day of Month, Rate): JPY,3,.0078
Enter (Currency, Day of Month, Rate): CHF,1,1.56
3 Currencies max. Please try again.
Enter (Currency, Day of Month, Rate): EUR, 5,1.11
Enter (Currency, Day of Month, Rate): EUR, 41,1.10
Day of month must be between 1 & 31. Please try again.
Enter (Currency, Day of Month, Rate): GBP,3,1.21
Enter (Currency, Day of Month, Rate): JPY,5,.0080
Enter (Currency, Day of Month, Rate): [null]
Enter Lookup (Currency, Day of Month, Amount): EUR, 5,1000.00
EUR 1000.00= USD 1100.00
Enter Lookup (Currency, Day of Month, Amount): EUR, 6,1000
Data Not Available
Enter Lookup (Currency, Day of Month, Amount): CHF,6,2000.00
Currency Not Available
Enter Lookup (Currency, Day of Month, Amount): GBP,9,2000.00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!