Advertisement
DeeAG

12.EvenNumber

Jan 15th, 2021
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _12.EvenNumber
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             bool isEven = false;
  10.  
  11.             while (!isEven)
  12.             {
  13.                 int input = Math.Abs(int.Parse(Console.ReadLine()));
  14.  
  15.                 if (input % 2 != 0)
  16.                 {
  17.                     Console.WriteLine("Please write an even number.");
  18.                     continue;
  19.                 }
  20.                 else
  21.                 {
  22.                     Console.WriteLine($"The number is: {input}");
  23.                     isEven = true;
  24.                     return;
  25.                 }
  26.             }
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement