Advertisement
JohnJuly

Homework13

Oct 23rd, 2023 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Homework13
  9. {
  10.     internal class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             const string ListenMelody = "1";
  15.             const string CompositionNumbers = "2";
  16.             const string ChangeTextColor = "3";
  17.             const string CommandExit = "exit";
  18.            
  19.             Console.WriteLine("Вы попали в меню выбора команд.");
  20.             string desireOperation = Console.ReadLine();
  21.  
  22.             while (desireOperation != CommandExit)
  23.             {
  24.                 Console.WriteLine("Введите действие из предложенных:");
  25.                 Console.WriteLine($"{ListenMelody} - прослушать мелодию.");
  26.                 Console.WriteLine($"{CompositionNumbers} - узнать произведение двух чисел.");
  27.                 Console.WriteLine($"{ChangeTextColor} - изменить цвет введенного текста.");
  28.                 Console.WriteLine($"{CommandExit} - для выхода из программы.");
  29.                 Console.WriteLine("Ваш выбор:  ");
  30.                 desireOperation = Console.ReadLine();
  31.                 Console.Clear();
  32.  
  33.                 switch (desireOperation)
  34.                 {
  35.                     case ListenMelody:
  36.                         Console.Beep(264, 125);
  37.                         Thread.Sleep(250);
  38.                         Console.Beep(264, 125);
  39.                         Thread.Sleep(125);
  40.                         Console.Beep(297, 500);
  41.                         Thread.Sleep(125);
  42.                         Console.Beep(264, 500);
  43.                         Thread.Sleep(125);
  44.                         Console.Beep(352, 500);
  45.                         Thread.Sleep(125);
  46.                         Console.Beep(330, 1000);
  47.                         Thread.Sleep(250);
  48.                         Console.Beep(264, 125);
  49.                         Thread.Sleep(250);
  50.                         Console.Beep(264, 125);
  51.                         Thread.Sleep(125);
  52.                         Console.Beep(297, 500);
  53.                         Thread.Sleep(125);
  54.                         Console.Beep(264, 500);
  55.                         Thread.Sleep(125);
  56.                         Console.Beep(396, 500);
  57.                         Thread.Sleep(125);
  58.                         Console.Beep(352, 1000);
  59.                         Thread.Sleep(250);
  60.                         break;
  61.  
  62.                     case CompositionNumbers:
  63.                         float firstNumber, secondNumber;
  64.                         Console.WriteLine($"Введите первое число");
  65.                         firstNumber = Convert.ToInt32(Console.ReadLine());
  66.                         Console.WriteLine($"Введите второе число");
  67.                         secondNumber = Convert.ToInt32(Console.ReadLine());
  68.                         float compositionNumbers = firstNumber * secondNumber;
  69.                         Console.WriteLine($"Результат произведения этих чисел равен - {compositionNumbers}");
  70.                         break;
  71.  
  72.                     case ChangeTextColor:
  73.                         Console.WriteLine("Ведите текст цвет которого хотите изменить");
  74.                         string userInput = Console.ReadLine();
  75.                         Console.ForegroundColor = ConsoleColor.Red;
  76.                         Console.Clear();
  77.                         Console.WriteLine(userInput);
  78.                         Console.ReadKey();
  79.                         Console.ResetColor();
  80.                         Console.Clear();
  81.                         break;
  82.  
  83.                     case CommandExit:
  84.                         Console.WriteLine("Вы вышли из программы");
  85.                         break;
  86.                 }
  87.             }
  88.         }
  89.     }
  90. }
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement