Advertisement
MustyElbow

CurrencyWallet

Sep 18th, 2023 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Net;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace CurrencyWallet
  10. {
  11.     internal class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             float rublesInWallet;
  16.             float lyresInWallet;
  17.             float yuanInWallet;
  18.  
  19.             float rubToLyres = 0.28f,
  20.                 lyresToRub = 3.53f,
  21.                 rubToYuan = 0.077f,
  22.                 yuanToRub = 13.18f,
  23.                 lyresToYuan = 0.27f,
  24.                 yuanToLyres = 3.69f;
  25.  
  26.             float exchangeCurrencyCount;
  27.  
  28.             int disiredOperation;
  29.             int exitCommand = 0;
  30.  
  31.             Console.WriteLine("Добро пожаловать в обменник валют");
  32.  
  33.             Console.Write("Введите баланс рублей ");
  34.             rublesInWallet = Convert.ToSingle(Console.ReadLine());
  35.             Console.Write("Введите баланс лиры ");
  36.             lyresInWallet = Convert.ToSingle(Console.ReadLine());
  37.             Console.Write("Введите баланс юаня ");
  38.             yuanInWallet = Convert.ToSingle(Console.ReadLine());
  39.             Console.WriteLine("Выберите необходимую операцию ");
  40.             Console.WriteLine("1 - обменять рубли на лиру");
  41.             Console.WriteLine("2 - обменять лиру на рубли");
  42.             Console.WriteLine("3 - обменять рубли на юань");
  43.             Console.WriteLine("4 - обменять юань на рубли");
  44.             Console.WriteLine("5 - обменять лиру на юань");
  45.             Console.WriteLine("6 - обменять юань на лиру");
  46.             Console.WriteLine($"Для завершения работы введите цифру {exitCommand}");
  47.             Console.Write("Ваш выбор: ");
  48.  
  49.             disiredOperation = Convert.ToInt32(Console.ReadLine());
  50.  
  51.             while (disiredOperation != exitCommand && disiredOperation <= int.MaxValue)
  52.             {
  53.                 if (disiredOperation == 1)
  54.                 {
  55.                     Console.WriteLine($"Вы выбрали операцию обмена рублей на лиру");
  56.                     Console.WriteLine("Сколько вы хотите обменять?");
  57.                     exchangeCurrencyCount = Convert.ToSingle(Console.ReadLine());
  58.  
  59.                     if (rublesInWallet >= exchangeCurrencyCount)
  60.                     {
  61.                         rublesInWallet -= exchangeCurrencyCount;
  62.                         lyresInWallet += exchangeCurrencyCount * rubToLyres;
  63.                         Console.WriteLine($"Вы успешно сконвертировали рубли на лиру! Теперь у вас {rublesInWallet} рублей и {lyresInWallet} лир");
  64.                     }
  65.                     else
  66.                     {
  67.                         Console.WriteLine("Недостаточно средств");
  68.                     }
  69.                 }
  70.  
  71.                 if (disiredOperation == 2)
  72.                 {
  73.                     Console.WriteLine("Обмен лиры на рубли");
  74.                     Console.WriteLine("Сколько вы хотите обменять?");
  75.                     exchangeCurrencyCount = Convert.ToSingle(Console.ReadLine());
  76.                     if (lyresInWallet >= exchangeCurrencyCount)
  77.                     {
  78.                         lyresInWallet -= exchangeCurrencyCount;
  79.                         rublesInWallet += exchangeCurrencyCount * lyresToRub;
  80.                         Console.WriteLine($"Вы успешно сконвертировали лиру на рубли! Теперь у вас {rublesInWallet} рублей и {lyresInWallet} лир");
  81.                     }
  82.                     else
  83.                     {
  84.                         Console.WriteLine("Недостаточно средств");
  85.                     }
  86.                 }
  87.  
  88.                 if (disiredOperation == 3)
  89.                 {
  90.                     Console.WriteLine("Обмен рублей на юань");
  91.                     Console.WriteLine("Сколько вы хотите обменять?");
  92.                     exchangeCurrencyCount = Convert.ToSingle(Console.ReadLine());
  93.                     if (rublesInWallet >= exchangeCurrencyCount)
  94.                     {
  95.                         rublesInWallet -= exchangeCurrencyCount;
  96.                         yuanInWallet += exchangeCurrencyCount * rubToYuan;
  97.                         Console.WriteLine($"Вы успешно сконвертировали рубли на юань! Теперь у вас {rublesInWallet} рублей и {yuanInWallet} юаней");
  98.                     }
  99.                     else
  100.                     {
  101.                         Console.WriteLine("Недостаточно средств");
  102.                     }
  103.                 }
  104.  
  105.                 if (disiredOperation == 4)
  106.                 {
  107.                     Console.WriteLine("Обмен юаней на рубли");
  108.                     Console.WriteLine("Сколько вы хотите обменять?");
  109.                     exchangeCurrencyCount = Convert.ToSingle(Console.ReadLine());
  110.                     if (yuanInWallet >= exchangeCurrencyCount)
  111.                     {
  112.                         yuanInWallet -= exchangeCurrencyCount;
  113.                         rublesInWallet += exchangeCurrencyCount * yuanToRub;
  114.                         Console.WriteLine($"Вы успешно сконвертировали юань на рубли! Теперь у вас {rublesInWallet} рублей и {yuanInWallet} юаней");
  115.                     }
  116.                     else
  117.                     {
  118.                         Console.WriteLine("Недостаточно средств");
  119.                     }
  120.                 }
  121.  
  122.                 if (disiredOperation == 5)
  123.                 {
  124.                     Console.WriteLine("Обмен лиры на юань");
  125.                     Console.WriteLine("Сколько вы хотите обменять?");
  126.                     exchangeCurrencyCount = Convert.ToSingle(Console.ReadLine());
  127.                     if (lyresInWallet >= exchangeCurrencyCount)
  128.                     {
  129.                         lyresInWallet -= exchangeCurrencyCount;
  130.                         yuanInWallet += exchangeCurrencyCount * lyresToYuan;
  131.                         Console.WriteLine($"Вы успешно сконвертировали лиры на юань! Теперь у вас {lyresInWallet} лир и {yuanInWallet} юаней");
  132.                     }
  133.                     else
  134.                     {
  135.                         Console.WriteLine("Недостаточно средств");
  136.                     }
  137.                 }
  138.  
  139.                 if (disiredOperation == 6)
  140.                 {
  141.                     Console.WriteLine("Обмен юаней на лиры");
  142.                     Console.WriteLine("Сколько вы хотите обменять?");
  143.                     exchangeCurrencyCount = Convert.ToSingle(Console.ReadLine());
  144.                     if (yuanInWallet >= exchangeCurrencyCount)
  145.                     {
  146.                         yuanInWallet -= exchangeCurrencyCount;
  147.                         lyresInWallet += exchangeCurrencyCount * yuanToLyres;
  148.                         Console.WriteLine($"Вы успешно сконвертировали лиры на юань! Теперь у вас {lyresInWallet} лир и {yuanInWallet} юаней");
  149.                     }
  150.                     else
  151.                     {
  152.                         Console.WriteLine("Недостаточно средств");
  153.                     }
  154.                 }
  155.  
  156.                 if (disiredOperation > 6)
  157.                 {
  158.                     Console.WriteLine("Введена неверная команда");
  159.                 }
  160.  
  161.                 Console.WriteLine($"Желаете продолжить? Если вы хотите отказаться от ввода напишете команду \"{exitCommand}\"");
  162.                 Console.Write("Выберите необходимую операцию: ");
  163.                 disiredOperation = Convert.ToInt32(Console.ReadLine());
  164.             }
  165.  
  166.             if (disiredOperation == exitCommand)
  167.             {
  168.                 Console.WriteLine("Программа завершила свою работу");
  169.             }
  170.         }
  171.     }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement