kwest87

Untitled

Oct 30th, 2023
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.32 KB | None | 0 0
  1. [StartCode]
  2. using System;
  3.  
  4. namespace povtorenie
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             const string CommandExit = "exit";
  11.             const string CommandRuble = "ruble";
  12.             const string CommandDollar = "dollar";
  13.             const string CommandYuan = "yuan";
  14.  
  15.             int temporaryRuble;
  16.             int temporaryDollar;
  17.             int temporaryYuan;
  18.             float ruble = 500;
  19.             float dollar = 500;
  20.             float yuan = 500;
  21.             float yuanToRuble = 0.25f;
  22.             float yuanToDollar = 0.5f;
  23.             float dollarToRuble = 0.5f;
  24.             float dollarToYuan = 2;
  25.             float rubleToDollar = 2;
  26.             float rubleToYuan = 4;
  27.             string menuInput;
  28.             bool works = true;
  29.  
  30.             while (works)
  31.             {
  32.                 Console.WriteLine($"У вас на счету :\n РУБЛИ - {ruble}\n ДОЛЛАРЫ - {dollar}\n ЮАНИ - {yuan}");
  33.                 Console.WriteLine("Выберите необходимую валюту либо выход :\n Команды : ruble , dollar , yuan , exit .");
  34.                 menuInput = Console.ReadLine();
  35.  
  36.                 switch (menuInput)
  37.                 {
  38.                     case CommandRuble:
  39.                         Console.Write("Сколько долларов использовать : ");
  40.                         temporaryDollar = Convert.ToInt32(Console.ReadLine());
  41.                         Console.WriteLine("Сколько юаней использовать : ");
  42.                         temporaryYuan = Convert.ToInt32(Console.ReadLine());
  43.                         dollar -= temporaryDollar;
  44.                         yuan -= temporaryYuan;
  45.                         ruble += temporaryDollar * dollarToRuble + temporaryYuan * yuanToRuble;
  46.                         break;
  47.                     case CommandDollar:
  48.                         Console.Write("Сколько рублей использовать : ");
  49.                         temporaryRuble = Convert.ToInt32(Console.ReadLine());
  50.                         Console.WriteLine("Сколько юаней использовать : ");
  51.                         temporaryYuan = Convert.ToInt32(Console.ReadLine());
  52.                         ruble -= temporaryRuble;
  53.                         yuan -= temporaryYuan;
  54.                         dollar += temporaryRuble * rubleToDollar + temporaryYuan * yuanToDollar;
  55.                         break;
  56.                     case CommandYuan:
  57.                         Console.Write("Сколько рублей использовать : ");
  58.                         temporaryRuble = Convert.ToInt32(Console.ReadLine());
  59.                         Console.WriteLine("Сколько долларов использовать : ");
  60.                         temporaryDollar = Convert.ToInt32(Console.ReadLine());
  61.                         ruble -= temporaryRuble;
  62.                         dollar -= temporaryDollar;
  63.                         yuan += temporaryRuble * rubleToYuan + temporaryDollar * dollarToYuan;
  64.                         break;
  65.                     case CommandExit:
  66.                         Console.WriteLine();
  67.                         works = false;
  68.                         break;
  69.                 }
  70.             }
  71.         }
  72.     }
  73. }
  74. [EndCode]
Advertisement
Add Comment
Please, Sign In to add comment