Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06_currencyConverter
- {
- class Program
- {
- static void Main(string[] args)
- {
- // user input
- double amount = double.Parse(Console.ReadLine());
- string currencyIN = Console.ReadLine();
- string currencyOUT = Console.ReadLine();
- // declare two variables for currency conversion
- double convertFrom = 0;
- double convertTo = 0;
- // assign value to convertFrom variable depending on user input
- if (currencyIN == "BGN")
- {
- convertFrom = 1.00;
- }
- else if (currencyIN == "USD")
- {
- convertFrom = 1.79549;
- }
- else if (currencyIN == "EUR")
- {
- convertFrom = 1.95583;
- } else
- {
- convertFrom = 2.53405;
- }
- // assign value to convertIn variable depending on user input
- if (currencyOUT == "BGN")
- {
- convertTo = 1.00;
- }
- else if (currencyOUT == "USD")
- {
- convertTo = 1.79549;
- }
- else if (currencyOUT == "EUR")
- {
- convertTo = 1.95583;
- }
- else
- {
- convertTo = 2.53405;
- }
- double result = Math.Round(amount * convertFrom / convertTo, 2);
- Console.WriteLine(result + " " + currencyOUT);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment