Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- internal class Program
- {
- static void Main(string[] args)
- {
- const string CommandShowData = "1";
- const string CommandShowTime = "2";
- const string CommandShowRandomNumber = "3";
- const string CommandClearConsole = "4";
- const string CommandExit = "5";
- int minRandom = 0;
- int maxRandom = 101;
- int number;
- string userInput;
- bool isWorkProgram = true;
- DateTime dateTime;
- Random random = new Random();
- while (isWorkProgram)
- {
- Console.WriteLine($"{CommandShowData} - Показать дату.\n" +
- $"{CommandShowTime} - показать время.\n" +
- $"{CommandShowRandomNumber} - показать случайное число.\n" +
- $"{CommandClearConsole} - Очистить консоль.\n" +
- $"{CommandExit} - Завершить программу.\n");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case CommandShowData:
- dateTime = DateTime.Now;
- Console.WriteLine(dateTime.ToShortDateString());
- Console.ReadKey();
- break;
- case CommandShowTime:
- dateTime = DateTime.Now;
- Console.WriteLine(dateTime.ToShortTimeString());
- Console.ReadKey();
- break;
- case CommandShowRandomNumber:
- number = random.Next(minRandom, maxRandom);
- Console.WriteLine(number);
- Console.ReadKey();
- break;
- case CommandClearConsole:
- Console.Clear();
- break;
- case CommandExit:
- isWorkProgram = false;
- Console.WriteLine("Программа завершена.");
- Console.ReadKey();
- break;
- default:
- Console.WriteLine("Ошибка ввода! Такой команды нет!");
- Console.ReadKey();
- break;
- }
- }
- Console.ReadKey();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement