Last active
February 6, 2025 20:06
-
-
Save 42BOBREEK/ab71c706eb28da79084b9fbb0d534969 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
namespace DZ1 | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Random random = new Random(); | |
int maxRandNum = 101; | |
bool programmWork = true; | |
const int CommandTextGeneral = 1; | |
const int CommandFirstText = 11; | |
const int CommandSecondText = 22; | |
const int CommandRandomNum = 2; | |
const int CommandConsoleClear = 3; | |
const int CommandExit = 4; | |
while (programmWork) | |
{ | |
Console.WriteLine($"\nДобро пожаловать в нашу программу!\nВведите номер нужной вам программы.\n{CommandTextGeneral}-Вывод текста" + | |
$"\n{CommandRandomNum}-показать случайное число\n{CommandConsoleClear}-Очистить консоль\n{CommandExit}- выйти из программы"); | |
int commandNum = Convert.ToInt32(Console.ReadLine()); | |
switch (commandNum) | |
{ | |
case CommandTextGeneral: | |
Console.WriteLine($"Какой текст вам вывести?\n{CommandFirstText}- что такое c#\n{CommandSecondText}-что такое c++"); | |
int writeCommandNum = Convert.ToInt32(Console.ReadLine()); | |
switch (writeCommandNum) | |
{ | |
case CommandFirstText: | |
Console.WriteLine("C# (C-Sharp) — это объектно-ориентированный язык программирования, " + | |
"разработанный компанией Microsoft в начале 2000-х годов. Он является частью экосистемы .NET."); | |
break; | |
case CommandSecondText: | |
Console.WriteLine("C++ – это мощный, высокопроизводительный язык программирования, " + | |
"созданный Бьёрном Страуструпом в 1983 году как расширение языка C."); | |
break; | |
default: | |
Console.WriteLine("Неверная команда! Введите правильную!"); | |
break; | |
} | |
break; | |
case CommandRandomNum: | |
int randomNumber = random.Next(0, maxRandNum); | |
Console.WriteLine($"\nСлучайное число от 0 до 100 - {randomNumber}"); | |
break; | |
case CommandConsoleClear: | |
Console.Clear(); | |
Console.WriteLine("Консоль очищена!"); | |
break; | |
case CommandExit: | |
Console.WriteLine("Закрытие программы!"); | |
programmWork = false; | |
break; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment