Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Security.Policy;
- internal class Program
- {
- static void Main(string[] args)
- {
- const string CommandConvertRublesToDollars = "1";
- const string CommandConvertDollarsToRubles = "2";
- const string CommandConvertRublesToYuan = "3";
- const string CommandConvertYuanToRubles = "4";
- const string CommandConvertDollarsToYuan = "5";
- const string CommandConvertYuanToDollars = "6";
- const string CommandExit = "7";
- const string CommandShowMistake = "Ошибка";
- float rub = 100000;
- float yuan = 200;
- float dollars = 50;
- float exchangeRublesToDollars = 0.01078f;
- float exchangeDollarsToRubles = 92.71f;
- float exchangeRublesToYuan = 0.0757f;
- float exchangeYuanToRubles = 13.22f;
- float exchangeDollarsToYuan = 7.01f;
- float exchangeYuanToDollars = 0.1426f;
- float amountMoney = 0;
- string userInput;
- bool isWorkProgram = true;
- while (isWorkProgram)
- {
- Console.Clear();
- Console.WriteLine($"На балансе:\nРублей = {rub}\nЮаней = {yuan}\nДолларов = {dollars}");
- Console.WriteLine($"{CommandConvertRublesToDollars} - Конвектировать Рубли в Доллары.\n" +
- $"{CommandConvertDollarsToRubles} - Конвектировать Доллары в Рубли.\n" +
- $"{CommandConvertRublesToYuan} - Конвектировать Рубли в Юани.\n" +
- $"{CommandConvertYuanToRubles} - Конвектировать Юани в Рубли.\n" +
- $"{CommandConvertDollarsToYuan} - Конвектировать Доллары в Юани.\n" +
- $"{CommandConvertYuanToDollars} - Конвектировать Юани в Доллары.\n" +
- $"{CommandExit} - Завершить программу.");
- userInput = Console.ReadLine();
- if (userInput != CommandExit)
- {
- Console.Write("Введите количество: ");
- amountMoney = Convert.ToInt32(Console.ReadLine());
- }
- if (userInput == CommandConvertRublesToDollars || userInput == CommandConvertRublesToYuan)
- {
- if (amountMoney <= rub)
- {
- rub -= amountMoney;
- }
- else
- {
- userInput = CommandShowMistake;
- }
- }
- else if (userInput == CommandConvertDollarsToRubles || userInput == CommandConvertDollarsToYuan)
- {
- if (amountMoney <= dollars)
- {
- dollars -= amountMoney;
- }
- else
- {
- userInput = CommandShowMistake;
- }
- }
- else if (userInput == CommandConvertYuanToRubles || userInput == CommandConvertYuanToDollars)
- {
- if (amountMoney <= yuan)
- {
- yuan -= amountMoney;
- }
- else
- {
- userInput = CommandShowMistake;
- }
- }
- switch (userInput)
- {
- case CommandConvertRublesToDollars:
- dollars += amountMoney * exchangeRublesToDollars;
- break;
- case CommandConvertDollarsToRubles:
- rub += amountMoney * exchangeDollarsToRubles;
- break;
- case CommandConvertRublesToYuan:
- yuan += amountMoney * exchangeRublesToYuan;
- break;
- case CommandConvertYuanToRubles:
- rub += amountMoney * exchangeYuanToRubles;
- break;
- case CommandConvertDollarsToYuan:
- yuan += amountMoney * exchangeDollarsToYuan;
- break;
- case CommandConvertYuanToDollars:
- dollars += amountMoney * exchangeYuanToDollars;
- break;
- case CommandExit:
- isWorkProgram = false;
- Console.WriteLine("Программа завершена.");
- break;
- case CommandShowMistake:
- Console.WriteLine("Недостаточно средств!");
- Console.ReadKey();
- break;
- default:
- Console.WriteLine("Ошибка ввода! Такой команды нет!");
- break;
- }
- }
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement