currency
Class CurrencyCalc
java.lang.Object
currency.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.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
currencies
public static final java.lang.String[] currencies
abbreviations
public static final java.lang.String[] abbreviations
rates
public static final double[] rates
CurrencyCalc
public CurrencyCalc()
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