kwest87

Untitled

Nov 1st, 2023
832
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.36 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3.  
  4. namespace ConsoleApp25
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             const string CommandExit = "7";
  11.             const string CommandYuanToRuble = "1";
  12.             const string CommandYuanToDollar = "2";
  13.             const string CommandDollarToRuble = "3";
  14.             const string CommandDollarToYuan = "4";
  15.             const string CommandRubleToDollar = "5";
  16.             const string CommandRubleToYuan = "6";
  17.  
  18.             int temporaryCurrency;
  19.             float ruble = 500;
  20.             float dollar = 500;
  21.             float yuan = 500;
  22.             float yuanToRuble = 0.25f;
  23.             float yuanToDollar = 0.5f;
  24.             float dollarToRuble = 0.5f;
  25.             float dollarToYuan = 2;
  26.             float rubleToDollar = 2;
  27.             float rubleToYuan = 4;
  28.             string menuInput;
  29.             bool isWorks = true;
  30.  
  31.             while (isWorks)
  32.             {
  33.                 Console.WriteLine($" У вас на счету :\n РУБЛИ - {ruble}\n ДОЛЛАРЫ - {dollar}\n ЮАНИ - {yuan}");
  34.                 Console.Write($"       Меню\n{CommandYuanToRuble})Юани в Рубли.\n{CommandYuanToDollar})Юани в Доллары.\n{CommandDollarToRuble})Доллары в рубли." +
  35.                     $"\n{CommandDollarToYuan})Доллары в юани.\n{CommandRubleToDollar})Рубли в доллары.\n{CommandRubleToYuan})Рубли в Юани.\n{CommandExit})Выход" +
  36.                     $"\n Укажите номер операции : ");
  37.                 menuInput = Console.ReadLine();
  38.  
  39.                 switch (menuInput)
  40.                 {
  41.                     case CommandYuanToRuble:
  42.                         Console.Write("Сколько юаней обменять в рубли :");
  43.                         temporaryCurrency = Convert.ToInt32(Console.ReadLine());
  44.  
  45.                         if (yuan >= temporaryCurrency)
  46.                         {
  47.                             yuan -= temporaryCurrency;
  48.                             ruble += temporaryCurrency * yuanToRuble;
  49.                         }
  50.                         else
  51.                         {
  52.                             Console.WriteLine("Недостаточно средств для операции.");
  53.                             Console.Read();
  54.                         }
  55.                         break;
  56.  
  57.                     case CommandYuanToDollar:
  58.                         Console.Write("Сколько юаней обменять на доллары :");
  59.                         temporaryCurrency = Convert.ToInt32(Console.ReadLine());
  60.  
  61.                         if (yuan >= temporaryCurrency)
  62.                         {
  63.                             yuan -= temporaryCurrency;
  64.                             dollar += temporaryCurrency * yuanToDollar;
  65.                         }
  66.                         else
  67.                         {
  68.                             Console.WriteLine("Недостаточно средств лоя операции.");
  69.                             Console.Read();
  70.                         }
  71.                         break;
  72.  
  73.                     case CommandDollarToRuble:
  74.                         Console.Write("Сколько долларов обменять на рубли :");
  75.                         temporaryCurrency = Convert.ToInt32(Console.ReadLine());
  76.  
  77.                         if (dollar >= temporaryCurrency)
  78.                         {
  79.                             dollar -= temporaryCurrency;
  80.                             ruble += temporaryCurrency * dollarToRuble;
  81.                         }
  82.                         else
  83.                         {
  84.                             Console.WriteLine("Недостаточно средств лоя операции.");
  85.                             Console.Read();
  86.                         }
  87.                         break;
  88.  
  89.                     case CommandDollarToYuan:
  90.                         Console.Write("Сколько долларов обменять на юани :");
  91.                         temporaryCurrency = Convert.ToInt32(Console.ReadLine());
  92.  
  93.                         if (dollar >= temporaryCurrency)
  94.                         {
  95.                             dollar -= temporaryCurrency;
  96.                             yuan += temporaryCurrency * dollarToYuan;
  97.                         }
  98.                         else
  99.                         {
  100.                             Console.WriteLine("Недостаточно средств лоя операции.");
  101.                             Console.Read();
  102.                         }
  103.                         break;
  104.  
  105.                     case CommandRubleToDollar:
  106.                         Console.Write("Сколько рублей обменять на доллары :");
  107.                         temporaryCurrency = Convert.ToInt32(Console.ReadLine());
  108.  
  109.                         if (ruble >= temporaryCurrency)
  110.                         {
  111.                             ruble -= temporaryCurrency;
  112.                             dollar += temporaryCurrency * rubleToDollar;
  113.                         }
  114.                         else
  115.                         {
  116.                             Console.WriteLine("Недостаточно средств лоя операции.");
  117.                             Console.Read();
  118.                         }
  119.                         break;
  120.  
  121.                     case CommandRubleToYuan:
  122.                         Console.Write("Сколько рублей обменять на юани :");
  123.                         temporaryCurrency = Convert.ToInt32(Console.ReadLine());
  124.  
  125.                         if (ruble >= temporaryCurrency)
  126.                         {
  127.                             ruble -= temporaryCurrency;
  128.                             yuan += temporaryCurrency * rubleToYuan;
  129.                         }
  130.                         else
  131.                         {
  132.                             Console.WriteLine("Недостаточно средств лоя операции.");
  133.                             Console.Read();
  134.                         }
  135.                         break;
  136.  
  137.                     case CommandExit:
  138.                         Console.WriteLine();
  139.                         isWorks = false;
  140.                         break;
  141.                 }
  142.  
  143.                 Console.Clear();
  144.             }
  145.         }
  146.     }
  147. }
  148. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment