Write a program that, given the exchange rate from euros to dollars (EUR->USD), and a list of values given in either euros or dollars, prints the sum of such values both in euros and in dollars.
For example, if we are given 1 EUR = 1.093 USD and the list
31 USD
2.40 EUR
27.25 USD
50 USD
The sum of all such values in euros is , whereas the sum of all such values in dollars is . Thus, the program must print both values as result.
Your program can only include iostream and
string, no other library can be used. Your program must not
store the input by any means and must not define nor use functions or
procedures other than those defined in the iostream and
string libraries. Failure to satisfy these requirements
will invalidate (final score = 0) your program.
Exam score: 2.5 Automatic part: 50%
The input starts with a strictly positive real number, that
represents how much dollars costs one euro. After that, several lines
follow, each one with a strictly positive real number
followed by either EUR or USD, representing
that
must be interpreted as a value in euros or dollars, respectively.
The output has the sum of the money represented by the given ’s printed twice, once in euros and once in dollars, separated by a blank space. Print both values with 4 digits after the decimal point. Use the following instructions at the beginning of your program to fix such precision:
cout.setf(ios::fixed);
cout.precision(4);
Input
1.093 31 USD 2.40 EUR 27.25 USD 50 USD
Output
101.4393 110.8732