Advertisement
DidiMilikina

12. Currency Converter

Sep 18th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7.  
  8.     double money;
  9.     string in_currency;
  10.     string out_currency;
  11.     cin >> money;
  12.     cin >> in_currency >> out_currency;
  13.  
  14.     string currency = " BGN";
  15.  
  16.  
  17.     if (in_currency == "USD")
  18.     {
  19.         money *= 1.79549;
  20.     }
  21.     else if (in_currency == "EUR")
  22.     {
  23.         money *= 1.95583;
  24.     }
  25.     else if (in_currency == "GBP")
  26.     {
  27.         money *= 2.53405;
  28.     }
  29.  
  30.     if (out_currency == "USD")
  31.     {
  32.         money /= 1.79549;
  33.         currency = " USD";
  34.     }
  35.     else if (out_currency == "EUR")
  36.     {
  37.         money /= 1.95583;
  38.         currency = " EUR";
  39.     }
  40.     else if (out_currency == "GBP")
  41.     {
  42.         money /= 2.53405;
  43.         currency = " GBP";
  44.     }
  45.  
  46.     cout << fixed << setprecision(2) << money << currency << endl;
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement