Advertisement
Guest User

currency_converter

a guest
Jun 20th, 2016
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.  
  5. namespace converter
  6. {
  7.     class Program
  8.     {
  9.  
  10.         static double convert(string a)
  11.         {
  12.             switch(a)
  13.             {
  14.                 case "BGN":
  15.                     return 1;
  16.                     break;
  17.                 case "USD":
  18.                     return 1.79549;
  19.                     break;
  20.                 case "EUR":
  21.                     return 1.95583;
  22.                 case "GBP":
  23.                     return 2.53405;
  24.                     break;
  25.                 default:
  26.                     return 1;
  27.                     break;
  28.             }
  29.         }
  30.         static void Main()
  31.         {
  32.             var amount = double.Parse(Console.ReadLine());
  33.             string currency_1 = Console.ReadLine();
  34.             string currency_2 = Console.ReadLine();
  35.  
  36.             double value1 = convert(currency_1);
  37.             double value2 = convert(currency_2);
  38.  
  39.             double result = (value1 / value2)*amount;
  40.             Console.WriteLine(Math.Round(result,2) + " " + currency_2);
  41.                
  42.  
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement