Advertisement
Anonim_999

Convertor

Nov 30th, 2020 (edited)
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.82 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 ConsoleApp5
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             bool isContinue = true;
  14.             int rubToUsd = 30, usdToRub = 100, euroToUsd = 112;
  15.             string userInput;
  16.             float rub, usd, euro;
  17.             float currencyCount;
  18.             Console.Write("Введите кол-во рублей: ");
  19.             rub = Convert.ToSingle(Console.ReadLine());
  20.             Console.Write("Введите кол-во долларов: ");
  21.             usd = Convert.ToSingle(Console.ReadLine());
  22.             Console.Write("Введите кол-во евро: ");
  23.             euro = Convert.ToSingle(Console.ReadLine());
  24.             while (isContinue)
  25.             {
  26.                 Console.WriteLine("1 - обменять рубли на доллары\n" +
  27.                 "2 - доллары на рубли\n" +
  28.                 "3 - евро в доллары\n" +
  29.                 "exit - для выхода");
  30.                 userInput = Console.ReadLine();
  31.                 Console.Clear();
  32.                 switch (userInput)
  33.                 {
  34.                     case "1":
  35.                         Console.Write("Обмен рублей на доллары\n" +
  36.                             "Сколько вы хотите обменять?: ");
  37.                         currencyCount = Convert.ToSingle(Console.ReadLine());
  38.                         if (rub >= currencyCount)
  39.                         {
  40.                             rub -= currencyCount;
  41.                             usd += currencyCount / rubToUsd;
  42.                         }
  43.                         else
  44.                         {
  45.                             Console.WriteLine("Не допустимое кол-во рублей");
  46.                         }
  47.                         break;
  48.                     case "2":
  49.                         Console.Write("Обмен долларов на рубли\n" +
  50.                            "Сколько вы хотите обменять?: ");
  51.                         currencyCount = Convert.ToSingle(Console.ReadLine());
  52.                         if (usd >= currencyCount)
  53.                         {
  54.                             usd -= currencyCount;
  55.                             rub += currencyCount * usdToRub;
  56.                         }
  57.                         else
  58.                         {
  59.                             Console.WriteLine("Не допустимое кол-во долларов");
  60.                         }
  61.                         break;
  62.                     case "3":
  63.                         Console.Write("Обмен евро на доллары\n" +
  64.                            "Сколько вы хотите обменять?: ");
  65.                         currencyCount = Convert.ToSingle(Console.ReadLine());
  66.                         if (euro >= currencyCount)
  67.                         {
  68.                             euro -= currencyCount;
  69.                             usd += currencyCount * euroToUsd;
  70.                         }
  71.                         else
  72.                         {
  73.                             Console.WriteLine("Не допустимое кол-во евро");
  74.                         }
  75.                         break;
  76.                     case "exit":
  77.                         isContinue = false;
  78.                         break;
  79.                     default:
  80.                         Console.WriteLine("Что-то пошло не так");
  81.                         break;
  82.                 }
  83.                 Console.WriteLine($"Рубли: {rub}\n" +
  84.                     $"Доллары: {usd}\n" +
  85.                     $"Евро: {euro}");
  86.             }
  87.             Console.ReadKey();
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement