Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isContinue = true;
- int rubToUsd = 30, usdToRub = 100, euroToUsd = 112;
- string userInput;
- float rub, usd, euro;
- float currencyCount;
- Console.Write("Введите кол-во рублей: ");
- rub = Convert.ToSingle(Console.ReadLine());
- Console.Write("Введите кол-во долларов: ");
- usd = Convert.ToSingle(Console.ReadLine());
- Console.Write("Введите кол-во евро: ");
- euro = Convert.ToSingle(Console.ReadLine());
- while (isContinue)
- {
- Console.WriteLine("1 - обменять рубли на доллары\n" +
- "2 - доллары на рубли\n" +
- "3 - евро в доллары\n" +
- "exit - для выхода");
- userInput = Console.ReadLine();
- Console.Clear();
- switch (userInput)
- {
- case "1":
- Console.Write("Обмен рублей на доллары\n" +
- "Сколько вы хотите обменять?: ");
- currencyCount = Convert.ToSingle(Console.ReadLine());
- if (rub >= currencyCount)
- {
- rub -= currencyCount;
- usd += currencyCount / rubToUsd;
- }
- else
- {
- Console.WriteLine("Не допустимое кол-во рублей");
- }
- break;
- case "2":
- Console.Write("Обмен долларов на рубли\n" +
- "Сколько вы хотите обменять?: ");
- currencyCount = Convert.ToSingle(Console.ReadLine());
- if (usd >= currencyCount)
- {
- usd -= currencyCount;
- rub += currencyCount * usdToRub;
- }
- else
- {
- Console.WriteLine("Не допустимое кол-во долларов");
- }
- break;
- case "3":
- Console.Write("Обмен евро на доллары\n" +
- "Сколько вы хотите обменять?: ");
- currencyCount = Convert.ToSingle(Console.ReadLine());
- if (euro >= currencyCount)
- {
- euro -= currencyCount;
- usd += currencyCount * euroToUsd;
- }
- else
- {
- Console.WriteLine("Не допустимое кол-во евро");
- }
- break;
- case "exit":
- isContinue = false;
- break;
- default:
- Console.WriteLine("Что-то пошло не так");
- break;
- }
- Console.WriteLine($"Рубли: {rub}\n" +
- $"Доллары: {usd}\n" +
- $"Евро: {euro}");
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement