11Currency Conversion

At some point, you might have to deal with currency exchange rates, and you’ll need to ensure your calculations are as precise as possible.

Write a program that converts currency. Specifically, convert euros to U.S. dollars. Prompt for the amount of money in euros you have, and prompt for the current exchange rate of the euro. Print out the new amount in U.S. dollars. The formula for currency conversion is

images/_pragprog/svg-0002.png

where

  • Amount to is the amount in U.S. dollars.

  • Amount from is the amount in euros.

  • rate from is the current exchange rate in euros.

  • rate to is the current exchange rate of the U.S. dollar.

Example Output

 
How many euros are ...

Get Exercises for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.