Advertisement
RedFlys

HomeWork9. Currency Convector

Aug 22nd, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp9.CurrencyConverter
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double ruble;
  10.             double dollar;
  11.             double euro;
  12.             double priceDollar = 63.95;
  13.             double priceEuro = 70.86;
  14.             double wantBuyValue;
  15.             int firstCurrencySelect = 1;
  16.             int secondCurrencySelect;
  17.             string changeCurrency = "\nВыберите валюту, в которую будем переводить: \n";
  18.             string errorLowMonye = "\nНельзя совершить данную операцию. Не хватает денег\n";
  19.             string errorRightNumber = "Пожалуйста введите корректный номер команды\n";
  20.  
  21.             Console.WriteLine("Введите, какое у вас кол-во рублей, долларов и евро:");
  22.             ruble = Convert.ToDouble(Console.ReadLine());
  23.             dollar = Convert.ToDouble(Console.ReadLine());
  24.             euro = Convert.ToDouble(Console.ReadLine());
  25.             Console.WriteLine("\nДальнейшее управление программой осуществляется числовым вводом. Первая цифра строчки означает команду операции.\n");
  26.  
  27.             while (firstCurrencySelect != 0)
  28.             {
  29.                 Console.WriteLine("Выберите валюту, которую хотите перевести:\n\n1. Рубли.\n2. Доллары. \n3. Евро. \n0. Выход из программы.");
  30.                 firstCurrencySelect = Convert.ToInt32(Console.ReadLine());
  31.  
  32.                 if (firstCurrencySelect == 1)
  33.                 {
  34.                     Console.WriteLine(changeCurrency + "\n1.Доллары \n2.Евро");
  35.                     secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
  36.                 }
  37.                 else if (firstCurrencySelect == 2)
  38.                 {
  39.                     Console.WriteLine(changeCurrency + "\n1.Рубли \n2.Евро");
  40.                     secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
  41.                 }
  42.                 else if (firstCurrencySelect == 3)
  43.                 {
  44.                     Console.WriteLine(changeCurrency + "\n1.Рубли \n2.Доллары");
  45.                     secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
  46.                 }
  47.                 else if (firstCurrencySelect == 0)
  48.                 {
  49.                     break;
  50.                 }
  51.                 else
  52.                 {
  53.                     Console.WriteLine(errorRightNumber);
  54.                     Console.ReadLine();
  55.                     continue;
  56.                 }
  57.  
  58.                 Console.WriteLine("\nКакую сумму вы желаете получить?\n");
  59.                 wantBuyValue = Convert.ToDouble(Console.ReadLine());
  60.  
  61.                 if (firstCurrencySelect == 1)
  62.                 {
  63.                     if (secondCurrencySelect == 1)
  64.                     {
  65.                         if (wantBuyValue * priceDollar < ruble)
  66.                         {
  67.                             dollar += wantBuyValue;
  68.                             ruble -= priceDollar * wantBuyValue;
  69.                         }
  70.                         else
  71.                         {
  72.                             Console.WriteLine(errorLowMonye);
  73.                             Console.ReadLine();
  74.                         }
  75.                     }
  76.                     else if (secondCurrencySelect == 2)
  77.                     {
  78.                         if (wantBuyValue * priceEuro < ruble)
  79.                         {
  80.                             euro += wantBuyValue;
  81.                             ruble -= priceEuro * wantBuyValue;
  82.                         }
  83.                         else
  84.                         {
  85.                             Console.WriteLine(errorLowMonye);
  86.                             Console.ReadLine();
  87.                         }
  88.                     }
  89.                     else
  90.                     {
  91.                         Console.WriteLine(errorRightNumber);
  92.                         Console.ReadLine();
  93.                     }
  94.                 }
  95.                 else if (firstCurrencySelect == 2)
  96.                 {
  97.                     if (secondCurrencySelect == 1)
  98.                     {
  99.                         if (wantBuyValue / priceDollar < dollar)
  100.                         {
  101.                             dollar -= wantBuyValue / priceDollar;
  102.                             ruble += wantBuyValue;
  103.                         }
  104.                         else
  105.                         {
  106.                             Console.WriteLine(errorLowMonye);
  107.                             Console.ReadLine();
  108.                         }
  109.                     }
  110.                     else if (secondCurrencySelect == 2)
  111.                     {
  112.                         if ((wantBuyValue * priceDollar) / priceEuro < dollar)
  113.                         {
  114.                             euro += wantBuyValue;
  115.                             dollar -= (wantBuyValue * priceDollar) / priceEuro;
  116.                         }
  117.                         else
  118.                         {
  119.                             Console.WriteLine(errorLowMonye);
  120.                             Console.ReadLine();
  121.                         }
  122.                     }
  123.                     else
  124.                     {
  125.                         Console.WriteLine(errorRightNumber);
  126.                         Console.ReadLine();
  127.                     }
  128.                 }
  129.                 else if (firstCurrencySelect == 3)
  130.                 {
  131.                     Console.WriteLine(changeCurrency + "\n1.Рубли \n2.Доллары");
  132.                     secondCurrencySelect = Convert.ToInt32(Console.ReadLine());
  133.                     if (secondCurrencySelect == 1)
  134.                     {
  135.                         if (wantBuyValue / priceEuro < euro)
  136.                         {
  137.                             euro -= wantBuyValue / priceEuro;
  138.                             ruble += wantBuyValue;
  139.                         }
  140.                         else
  141.                         {
  142.                             Console.WriteLine(errorLowMonye);
  143.                             Console.ReadLine();
  144.                         }
  145.                     }
  146.                     else if (secondCurrencySelect == 2)
  147.                     {
  148.                         if ((wantBuyValue * priceEuro) / priceDollar < euro)
  149.                         {
  150.                             dollar += wantBuyValue;
  151.                             euro -= (wantBuyValue * priceEuro) / priceDollar;
  152.                         }
  153.                         else
  154.                         {
  155.                             Console.WriteLine(errorLowMonye);
  156.                             Console.ReadLine();
  157.                         }
  158.                     }
  159.                     else
  160.                     {
  161.                         Console.WriteLine(errorRightNumber);
  162.                         Console.ReadLine();
  163.                     }
  164.                 }
  165.                 else
  166.                 {
  167.                     Console.WriteLine(errorRightNumber);
  168.                     Console.ReadLine();
  169.                 }
  170.  
  171.                 Console.WriteLine($"\nТеперь у вас {ruble} рублей, {dollar} долларов и {euro} евро. \n");
  172.             }
  173.             Console.WriteLine("\nДо свидания.");
  174.             Console.ReadLine();
  175.         }
  176.  
  177.     }
  178. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement