currency
Class CurrencyCalc

java.lang.Object
  extended bycurrency.CurrencyCalc

public class CurrencyCalc
extends java.lang.Object

This class calculates currency conversion. The application program can specify the initial currency amount, the currency the amount is in and which currency the initial amount should be converted to.


Field Summary
static java.lang.String[] abbreviations
           
static java.lang.String[] currencies
           
static double[] rates
           
 
Constructor Summary
CurrencyCalc()
           
 
Method Summary
 java.lang.String convertFromDollars(java.lang.String amount, java.lang.String currency)
           
 java.lang.String[] getAbbreviations()
           
 java.lang.String[] getCurrencies()
           
 java.lang.String getFromAbbreviation()
           
 java.lang.String getFromAmount()
           
 java.lang.String getFromCurrency()
           
 java.lang.String getToAbbreviation()
           
 java.lang.String getToAmount()
           
 java.lang.String getToCurrency()
           
 boolean isFromAmountValid()
           
 void setFromAmount(java.lang.String amount)
          Specifies the initial amount
 void setFromCurrency(java.lang.String currency)
          Specifies the initial currency
 void setToCurrency(java.lang.String currency)
          Specifies the resulting currency
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currencies

public static final java.lang.String[] currencies

abbreviations

public static final java.lang.String[] abbreviations

rates

public static final double[] rates
Constructor Detail

CurrencyCalc

public CurrencyCalc()
Method Detail

setFromCurrency

public void setFromCurrency(java.lang.String currency)
Specifies the initial currency

Parameters:
currency - the currency name for the initial amount (e.g. "Mexican Peso")

getFromCurrency

public java.lang.String getFromCurrency()
Returns:
the name of the currency for the initial amount

setToCurrency

public void setToCurrency(java.lang.String currency)
Specifies the resulting currency

Parameters:
currency - the currency name for the resulting amount (e.g. "Mexican Peso")

getToCurrency

public java.lang.String getToCurrency()
Returns:
the name of the currency for the resulting amount

getFromAbbreviation

public java.lang.String getFromAbbreviation()
                                     throws java.lang.Exception
Returns:
the abbreviated name of the currency for the initial amount
Throws:
java.lang.Exception

getToAbbreviation

public java.lang.String getToAbbreviation()
                                   throws java.lang.Exception
Returns:
the abbreviated name of the currency for the resulting amount
Throws:
java.lang.Exception

setFromAmount

public void setFromAmount(java.lang.String amount)
Specifies the initial amount

Parameters:
amount - the initial amount to be converted

getFromAmount

public java.lang.String getFromAmount()
Returns:
initial amount to be converted

isFromAmountValid

public boolean isFromAmountValid()
Returns:
true if initial amount is a valid floating point number

getToAmount

public java.lang.String getToAmount()
                             throws java.lang.Exception
Returns:
the resulting amount given the initial amount, currency and the resulting currency
Throws:
java.lang.Exception

getCurrencies

public java.lang.String[] getCurrencies()
Returns:
the list of currencies as an array of strings

getAbbreviations

public java.lang.String[] getAbbreviations()
Returns:
the list of currency abbreviations as an array of strings

convertFromDollars

public java.lang.String convertFromDollars(java.lang.String amount,
                                           java.lang.String currency)
                                    throws java.lang.Exception
Throws:
java.lang.Exception