Advertisement
RedFlys

Home Work 2.2

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