#K95247. Currency Conversion Calculator

    ID: 38821 Type: Default 1000ms 256MiB

Currency Conversion Calculator

Currency Conversion Calculator

You are given an amount and two currency codes: the currency the amount is in (from_currency) and the currency you want to convert it to (to_currency). The conversion is performed using the following exchange rates:

If from_currency is not USD, multiply amount by its corresponding exchange rate. If to_currency is not USD, multiply the result by its corresponding reverse rate. In mathematical terms, if we denote the initial amount by \(A\), the exchange rate for from_currency (if not USD) by \(r_{from}\) and the reverse rate for to_currency (if not USD) by \(r_{to}\), the result is computed as:

[ \text{result} = A \times r_{from} \times r_{to}, ]

Note: If either the from_currency or to_currency is "USD", its corresponding multiplier is \(1\).

The available conversion rates are:

  • Exchange rates (when converting from a non-USD currency to USD):
    • EUR: 1.12
    • GBP: 1.30
    • JPY: 0.0091
    • INR: 0.013
  • Reverse rates (when converting from USD to a non-USD currency):
    • EUR: 0.89
    • GBP: 0.77
    • JPY: 109.89
    • INR: 76.60

Your task is to perform the conversion based on the input and output the resulting amount.

inputFormat

The input consists of a single line with three tokens separated by space:

  1. A number amount (can be treated as a floating point value).
  2. A string from_currency (one of USD, EUR, GBP, JPY, INR).
  3. A string to_currency (one of USD, EUR, GBP, JPY, INR).

outputFormat

Output a single number representing the converted amount. The answer will be considered correct if it is within an absolute error of \(10^{-5}\) of the correct answer.

## sample
100 EUR JPY
12307.68