ranee

обмен валют

Jun 17th, 2020 (edited)
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Dynamic;
  5. using System.Linq;
  6. using System.Runtime.Serialization;
  7. using System.Text;
  8. using System.Threading;
  9. using System.Threading.Tasks;
  10. namespace CSLight
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             float rubToUsd = 71.21F, usdToRub = 68.16F, rubToEur = 80.49F, eurToRub = 77.04F, usdToEur = 1.1060F, eurToUsd = 1.1510F;
  17.             float rub, usd, eur, currencyCount;
  18.             string comand;
  19.             Console.Write("Введите баланс долларов:");
  20.             usd = Convert.ToSingle(Console.ReadLine());
  21.             Console.Write("Введите баланс рублей:");
  22.             rub = Convert.ToSingle(Console.ReadLine());
  23.             Console.Write("Введите баланс евро:");
  24.             eur = Convert.ToSingle(Console.ReadLine());
  25.             Console.WriteLine("Добро пожаловать в обменник, у нас вы можете обменять три валютные пары(usd/rub/eur)");
  26.             while (true)
  27.             {
  28.                 Console.WriteLine("Обменять доллары на рубли - 1 ");
  29.                 Console.WriteLine("Обменять рубли на доллары - 2");
  30.                 Console.WriteLine("Обменять рубли на евро - 3");
  31.                 Console.WriteLine("Обменять евро на рубли - 4");
  32.                 Console.WriteLine("Обменять доллары на евро - 5");
  33.                 Console.WriteLine("Обменять евро на доллары - 6");
  34.                 Console.WriteLine("Выйти из обменника - 7");
  35.                 Console.WriteLine($"Текуший баланс: {rub} рублей,{usd} долларов, {eur} евро");
  36.                 comand = Console.ReadLine();
  37.                 if(comand == "7")
  38.                 {
  39.                     break;
  40.                 }
  41.                 else if(comand == "1")
  42.                 {
  43.                     Console.Write("Какое количество долларов вы желаете обменять:");
  44.                     currencyCount = Convert.ToSingle(Console.ReadLine());
  45.                     if(usd >= currencyCount)
  46.                     {
  47.                         usd -= currencyCount;
  48.                         rub += currencyCount * usdToRub;
  49.                     }
  50.                     else
  51.                     {
  52.                         Console.Write("Недопустимое значение долларов.");
  53.                     }
  54.                 }
  55.                 else if (comand == "2")
  56.                 {
  57.                     Console.Write("Какое количество рублей вы желаете обменять:");
  58.                     currencyCount = Convert.ToSingle(Console.ReadLine());
  59.                     if (rub >= currencyCount)
  60.                     {
  61.                         rub -= currencyCount;
  62.                         usd += currencyCount / rubToUsd;
  63.                     }
  64.                     else
  65.                     {
  66.                         Console.Write("Недопустимое значение рублей.");
  67.                     }
  68.                 }
  69.                 else if (comand == "3")
  70.                 {
  71.                     Console.Write("Какое количество рублей вы желаете обменять:");
  72.                     currencyCount = Convert.ToSingle(Console.ReadLine());
  73.                     if (rub >= currencyCount)
  74.                     {
  75.                         rub -= currencyCount;
  76.                         eur += currencyCount / rubToEur;
  77.                     }
  78.                     else
  79.                     {
  80.                         Console.Write("Недопустимое значение рублей.");
  81.                     }
  82.                 }
  83.                 else if (comand == "4")
  84.                 {
  85.                     Console.Write("Какое количество евро вы желаете обменять:");
  86.                     currencyCount = Convert.ToSingle(Console.ReadLine());
  87.                     if (rub >= currencyCount)
  88.                     {
  89.                         eur -= currencyCount;
  90.                         rub += currencyCount * eurToRub;
  91.                     }
  92.                     else
  93.                     {
  94.                         Console.Write("Недопустимое значение евро.");
  95.                     }
  96.                 }
  97.                 else if (comand == "5")
  98.                 {
  99.                     Console.Write("Какое количество долларов вы желаете обменять:");
  100.                     currencyCount = Convert.ToSingle(Console.ReadLine());
  101.                     if (rub >= currencyCount)
  102.                     {
  103.                         usd -= currencyCount;
  104.                         eur += currencyCount / usdToEur;
  105.                     }
  106.                     else
  107.                     {
  108.                         Console.Write("Недопустимое значение долларов.");
  109.                     }
  110.                 }
  111.                 else if (comand == "6")
  112.                 {
  113.                     Console.Write("Какое количество евро вы желаете обменять:");
  114.                     currencyCount = Convert.ToSingle(Console.ReadLine());
  115.                     if (rub >= currencyCount)
  116.                     {
  117.                         eur -= currencyCount;
  118.                         usd += currencyCount * eurToUsd;
  119.                     }
  120.                     else
  121.                     {
  122.                         Console.Write("Недопустимое значение евро.");
  123.                     }
  124.                 }
  125.                 else if (comand != "1" || comand != "2" || comand != "3" || comand != "4" || comand != "5" || comand != "6" || comand != "7")
  126.                 {
  127.                     Console.WriteLine("Номера операции не существует.");
  128.                 }
  129.             }
  130.  
  131.         }
  132.     }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment