Advertisement
TwinFrame

Study_Cycles

Dec 9th, 2020 (edited)
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clight_30_LoopPrintText
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string userText;
  10.             string userNumber;
  11.             bool isNumber = false;
  12.             bool isOpen = true;
  13.  
  14.             while (isOpen == true)
  15.             {
  16.                 Console.Clear();
  17.                 Console.Write("Привет, напиши своё сообщение: ");
  18.                 userText = Console.ReadLine();
  19.                 Console.WriteLine();
  20.                 Console.Write("Сколько раз повторить: ");
  21.                 userNumber = Console.ReadLine();
  22.                 Console.WriteLine();
  23.                 isNumber = Int32.TryParse(userNumber, out int value);
  24.  
  25.                 if (isNumber == true && value >= 0)
  26.                 {
  27.                     for (int i = 0; i < value; i++)
  28.                     {
  29.                         Console.WriteLine(userText);
  30.                     }
  31.  
  32.                     Console.WriteLine();
  33.                     Console.Write("Повторить? Да - \"Y\": ");
  34.                     ConsoleKeyInfo key = Console.ReadKey();
  35.  
  36.                     switch (key.Key)
  37.                     {                        
  38.                         case ConsoleKey.Y:
  39.                             break;
  40.  
  41.                         default:
  42.                             isOpen = false;
  43.                             break;
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement