#K95782. Yen-Dollar Currency Converter
Yen-Dollar Currency Converter
Yen-Dollar Currency Converter
This problem requires you to implement a currency conversion tool. You are given two conversion rates: one for converting from Japanese Yen to US Dollar and another for converting from US Dollar to Japanese Yen. Then, you are provided with a number of queries. Each query is in the format C amount
, where C
is either Y
(for converting Yen to Dollar) or D
(for converting Dollar to Yen), and amount
is a floating-point value.
Your task is to compute the conversion for each query. The result for each conversion must be rounded to 2 decimal places.
Formally, if the query is Y amount then the answer is given by:
\( result = amount \times \text{yen_to_dollar} \)
Similarly, if the query is D amount then the answer is given by:
\( result = amount \times \text{dollar_to_yen} \)
Print each converted result on a separate line.
inputFormat
The first line of input contains two space-separated floats: yen_to_dollar
and dollar_to_yen
.
The second line contains an integer Q
representing the number of queries.
Each of the next Q
lines contains a query in the format C amount
, where C
is either Y
or D
and amount
is a float.
outputFormat
For each query, print the converted amount on a new line. The result must be rounded to 2 decimal places.
## sample0.0091 110.35
3
Y 1000
D 50
Y 2000
9.10
5517.50
18.20
</p>