Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace HW_2025
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- const string CommandRubToUsd = "RUB/USD";
- const string CommandRubToEur = "RUB/EUR";
- const string CommandUsdToRub = "USD/RUB";
- const string CommandUsdToEur = "USD/EUR";
- const string CommandEurToRub = "EUR/RUB";
- const string CommandEurToUsd = "EUR/USD";
- const string CommandBalance = "/Balance";
- const string CommandClearConsole = "/ClearConsole";
- const string CommandExit = "/Exit";
- const string CommandHelp = "/Help";
- int secondsToMilliseconds = 1000 * 3;
- double usdToEurRate = 0.85;
- double usdToRubRate = 75.0;
- double eurToUsdRate = 1.18;
- double eurToRubRate = 88.0;
- double rubToUsdRate = 0.0104;
- double rubToEurRate = 0.011;
- double balanceRub = 10000;
- double balanceUsd = 100;
- double balanceEur = 50;
- double userAmountСurrency;
- bool isWork = true;
- string userInput;
- Console.WriteLine("Бот Сonverter к Вашем уcлугам.\n" +
- $"Узнайте свой баланс {CommandBalance}\n" +
- $"Узнать возможности можно через {CommandHelp}\n");
- while (isWork)
- {
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case CommandClearConsole:
- Console.WriteLine("Консоль будет очищена через 3 секунды\n");
- System.Threading.Thread.Sleep(secondsToMilliseconds);
- Console.Clear();
- break;
- case CommandHelp:
- Console.WriteLine($"Команды чтобы обменять:\n" +
- $"-------\n" +
- $"{CommandRubToUsd}\n" +
- $"{CommandRubToEur}\n" +
- $"-------\n" +
- $"{CommandUsdToRub}\n" +
- $"{CommandUsdToEur}\n" +
- $"-------\n" +
- $"{CommandEurToRub}\n" +
- $"{CommandEurToUsd}\n");
- break;
- case CommandBalance:
- Console.WriteLine($"Ваш баланс:\n" +
- $"############\n" +
- $"RUB: {balanceRub}\n" +
- $"USD: {balanceUsd}\n" +
- $"EUR: {balanceEur}\n" +
- $"############");
- break;
- case CommandExit:
- isWork = false;
- Console.WriteLine("Программа закрыта");
- break;
- case CommandRubToUsd:
- Console.Write("Введите сумму для конвертации: ");
- userAmountСurrency = Convert.ToInt32(Console.ReadLine());
- if (userAmountСurrency < 0)
- {
- Console.WriteLine("Ошибка: Сумма не может быть отрицательной.");
- }
- else if(userAmountСurrency > balanceRub)
- {
- Console.WriteLine($"Ошибка: Недостаточно средств на балансе. Ваш счет = {balanceRub}\"");
- }
- else
- {
- balanceRub -= userAmountСurrency;
- balanceUsd += userAmountСurrency * rubToUsdRate;
- Console.WriteLine($"Произведен обмен {CommandRubToUsd}");
- }
- break;
- case CommandRubToEur:
- Console.Write("Введите сумму для конвертации: ");
- userAmountСurrency = Convert.ToInt32(Console.ReadLine());
- if (userAmountСurrency < 0)
- {
- Console.WriteLine("Ошибка: Сумма не может быть отрицательной.");
- }
- else if (userAmountСurrency > balanceRub)
- {
- Console.WriteLine($"Ошибка: Недостаточно средств на балансе. Ваш счет = {balanceRub}");
- }
- else
- {
- balanceRub -= userAmountСurrency;
- balanceEur += userAmountСurrency * rubToEurRate;
- Console.WriteLine($"Произведен обмен {CommandRubToEur}");
- }
- break;
- case CommandUsdToRub:
- Console.Write("Введите сумму для конвертации: ");
- userAmountСurrency = Convert.ToInt32(Console.ReadLine());
- if (userAmountСurrency < 0)
- {
- Console.WriteLine("Ошибка: Сумма не может быть отрицательной.");
- }
- else if (userAmountСurrency > balanceUsd)
- {
- Console.WriteLine($"Ошибка: Недостаточно средств на балансе. Ваш счет = {balanceUsd}");
- }
- else
- {
- balanceUsd -= userAmountСurrency;
- balanceRub += userAmountСurrency * usdToRubRate;
- Console.WriteLine($"Произведен обмен {CommandUsdToRub}");
- }
- break;
- case CommandUsdToEur:
- Console.Write("Введите сумму для конвертации: ");
- userAmountСurrency = Convert.ToInt32(Console.ReadLine());
- if (userAmountСurrency < 0)
- {
- Console.WriteLine("Ошибка: Сумма не может быть отрицательной.");
- }
- else if (userAmountСurrency > balanceUsd)
- {
- Console.WriteLine($"Ошибка: Недостаточно средств на балансе. Ваш счет = {balanceUsd}");
- }
- else
- {
- balanceUsd -= userAmountСurrency;
- balanceEur += userAmountСurrency * usdToEurRate;
- Console.WriteLine($"Произведен обмен {CommandUsdToEur}");
- }
- break;
- case CommandEurToRub:
- Console.Write("Введите сумму для конвертации: ");
- userAmountСurrency = Convert.ToInt32(Console.ReadLine());
- if (userAmountСurrency < 0)
- {
- Console.WriteLine("Ошибка: Сумма не может быть отрицательной.");
- }
- else if (userAmountСurrency > balanceEur)
- {
- Console.WriteLine($"Ошибка: Недостаточно средств на балансе. Ваш счет = {balanceEur}");
- }
- else
- {
- balanceEur -= userAmountСurrency;
- balanceRub += userAmountСurrency * eurToRubRate;
- Console.WriteLine($"Произведен обмен {CommandEurToRub}");
- }
- break;
- case CommandEurToUsd:
- Console.Write("Введите сумму для конвертации: ");
- userAmountСurrency = Convert.ToInt32(Console.ReadLine());
- if (userAmountСurrency < 0)
- {
- Console.WriteLine("Ошибка: Сумма не может быть отрицательной.");
- }
- else if (userAmountСurrency > balanceEur)
- {
- Console.WriteLine($"Ошибка: Недостаточно средств на балансе. Ваш счет = {balanceEur}");
- }
- else
- {
- balanceEur -= userAmountСurrency;
- balanceUsd += userAmountСurrency * eurToUsdRate;
- Console.WriteLine($"Произведен обмен {CommandEurToUsd}");
- }
- break;
- default:
- Console.WriteLine("Нет такой комманды");
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement