kwest87

Untitled

Dec 26th, 2023
847
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net.Http.Headers;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp12
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             const int CommandDollarToRuble = 1;
  15.             const int CommandYuanToRuble = 2;
  16.             const int CommandDollarToYuan = 3;
  17.             const int CommandRubleToYuan = 4;
  18.             const int CommandRubleToDollar = 5;
  19.             const int CommandYuanToDollar = 6;
  20.             const int CommandExit = 7;
  21.  
  22.             float rubleWallet = 1000;
  23.             float dollarWallet = 1000;
  24.             float yuanWallet = 1000;
  25.             float dollarToRuble = 0.5f;
  26.             float yuanToRuble = 0.25f;
  27.             float dollarToYuan = 2f;
  28.             float rubleToYuan = 4f;
  29.             float rubleToDollar = 2f;
  30.             float yuanToDollar = 0.5f;
  31.             bool isWork = true;
  32.             int userInput;
  33.  
  34.             while (isWork)
  35.             {
  36.                 Console.WriteLine($"Баланс : рубли : {rubleWallet}, доллары : {dollarWallet}, юани : {yuanWallet}.");
  37.                 Console.WriteLine($"Какой обмен вас интересует :\n {CommandDollarToRuble})Доллары на рубли\n {CommandYuanToRuble})Юани на рубли\n " +
  38.                     $"{CommandRubleToYuan})Рубли на юани\n {CommandDollarToYuan})Доллары на юани\n {CommandRubleToDollar})Рубли на доллары\n " +
  39.                     $"{CommandYuanToDollar})Юани на доллары\n {CommandExit})Выход");
  40.                 userInput = Convert.ToInt32(Console.ReadLine());
  41.  
  42.                 switch (userInput)
  43.                 {
  44.                     case CommandDollarToRuble:
  45.                         Console.Write("Сколько валюты обменять : ");
  46.                         userInput = Convert.ToInt32(Console.ReadLine());
  47.  
  48.                         if (userInput < dollarWallet)
  49.                         {
  50.                             dollarWallet -= userInput;
  51.                             rubleWallet += userInput * dollarToRuble;
  52.                         }
  53.                         break;
  54.  
  55.                     case CommandYuanToRuble:
  56.                         Console.Write("Сколько валюты обменять : ");
  57.                         userInput = Convert.ToInt32(Console.ReadLine());
  58.  
  59.                         if (userInput < yuanWallet)
  60.                         {
  61.                             yuanWallet -= userInput;
  62.                             rubleWallet += userInput * yuanToRuble;
  63.                         }
  64.                         break;
  65.  
  66.                     case CommandDollarToYuan:
  67.                         Console.Write("Сколько валюты обменять : ");
  68.                         userInput = Convert.ToInt32(Console.ReadLine());
  69.  
  70.                         if (userInput < dollarWallet)
  71.                         {
  72.                             dollarWallet -= userInput;
  73.                             yuanWallet += userInput * dollarToYuan;
  74.                         }
  75.                         break;
  76.  
  77.                     case CommandRubleToYuan:
  78.                         Console.Write("Сколько валюты обменять : ");
  79.                         userInput = Convert.ToInt32(Console.ReadLine());
  80.  
  81.                         if (userInput < rubleWallet)
  82.                         {
  83.                             rubleWallet -= userInput;
  84.                             yuanWallet += userInput * rubleToYuan;
  85.                         }
  86.                         break;
  87.  
  88.                     case CommandRubleToDollar:
  89.                         Console.Write("Сколько валюты обменять : ");
  90.                         userInput = Convert.ToInt32(Console.ReadLine());
  91.  
  92.                         if (userInput < rubleWallet)
  93.                         {
  94.                             rubleWallet -= userInput;
  95.                             dollarWallet += userInput * rubleToDollar;
  96.                         }
  97.                         break;
  98.  
  99.                     case CommandYuanToDollar:
  100.                         Console.Write("Сколько валюты обменять : ");
  101.                         userInput = Convert.ToInt32(Console.ReadLine());
  102.  
  103.                         if (userInput < yuanWallet)
  104.                         {
  105.                             yuanWallet -= userInput;
  106.                             dollarWallet += userInput * yuanToDollar;
  107.                         }
  108.                         break;
  109.  
  110.                     case CommandExit:
  111.                         isWork = false;
  112.                         break;
  113.                 }
  114.  
  115.                 Console.Clear();
  116.             }
  117.         }
  118.     }
  119. }
Advertisement
Add Comment
Please, Sign In to add comment