Trying to build a currency converter, unsure of next step
<p>I'm working on a class project and I cannot seem to figure out what to do next.  The instructions read: </p>

<p>•   it contains a public method named getFxRate that returns a double meant to represent the exchange rate between the currency codes passed in as the first and second String arguments.  The first String is the source or “in” currency, whereas the second is the destination or “out” currency.</p>

<p>I know i'm supposed to use that space to find out how to call one of the rates from the array, but i'm not sure how to do it.</p>

<p>This class will be linked to an html page, where the user will pick two currencies and then type an amount in, so getting the class to read which option they chose is another story</p>

<pre><code>public class fxDataModel {

/* create array for currency codes */
private static final String[] codes = {"CAD", "EUR", "GBP", "USD"};

/* create and populate 2d array for conversion */
private static final double[][] rates = 
{ {1.0, 0.624514066, 0.588714763, 0.810307 },
  {1.601244959, 1.0, 0.942676548, 1.2975},
  {1.698615463, 1.060809248, 1.0, 1.3764},
  {1.234100162, 0.772200772, 0.726532984, 1.0} };

public String[] getFxCurrencies(){
    return codes;
}

public double getFxRate (final int inCode, final int outCode){
int inCurr, outCurr;
    double rate;

    for (inCurr = 0; inCurr &lt; 4; inCurr++){
        String inCurrency = codes[inCurr];
        if (inCode.equals(inCurrency)) {
            break;
        }
    }

    for (outCurr = 0; outCurr &lt; 4; outCurr++){
        String outCurrency = codes[outCurr];
        if (outCode.equals(outCurrency)) {
            break;
        }
    }

    rate = rates[inCurr][outCurr];
    return rate;

}



}
</code></pre>

<p>EDIT: this is the hint my professor gave us</p>

<p>the prototype for getFxRate is
public double getFxRate( String inCurrency, String outCurrency )
So given the inCurrency ( for example, "USD" ) and the outCurrency ( for example, "CAD" ), the method getFxRate looks in the array F/X rates and returns the one that would translate USD to CAD.  Now, the array of F/X rates is double[][], that is a two dimensional array.  In my hypothetical example, the value at [ 3 ][ 0 ] answers the question as to which rate in the rates array converts USD -> CAD.  That's because in the currencies array which is String[], CAD exists at the 0th position and USD exist at the 3rd.  So given inCurrency and outCurrency, find there indices in the String[] array of currencies and use those indexes in the rates array to return that one single value.  It's pretty straightforward Java to loop through the array of Strings to find the matching currency and it's associated index.  That's Java I stuff and I leave that to you, but do think loops.</p>
