Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- string userInput;
- bool isWorking = true;
- string wordToExit = "выход";
- Dictionary<string, decimal> currencies = new Dictionary<string, decimal>();
- currencies.Add("USD", 89.52m);
- currencies.Add("EUR", 97.09m);
- currencies.Add("CHY", 12.44m);
- currencies.Add("TRY", 2.96m);
- currencies.Add("INR", 1.08m);
- Print(currencies);
- while(isWorking)
- {
- Console.WriteLine($"Введите значение указанные выше. Для выхода из программы напишите \'{wordToExit}\'");
- userInput = Console.ReadLine();
- if(userInput.ToLower() == wordToExit)
- {
- isWorking = false;
- }
- else if(currencies.ContainsKey(userInput))
- {
- Console.WriteLine($"{userInput} - {currencies[userInput]}");
- }
- else
- {
- Console.WriteLine($"{userInput} нет в списке");
- }
- }
- Console.ReadKey();
- }
- private static void Print(Dictionary<string,decimal> currencies)
- {
- Console.WriteLine("Значения:");
- foreach (var item in currencies)
- {
- Console.WriteLine($"\n- {item.Key}");
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement