using System;
namespace ConsoleApp1
{
internal class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Enter number: ");
string userInput = Console.ReadLine();
CheckNumber(userInput);
}
//CheckNumber()
public static void CheckNumber(string stringNumber) {
double doubleNumber;
bool success = double.TryParse(stringNumber, out doubleNumber);
if (success)
{
if (doubleNumber % 2 == 0)
{
Console.WriteLine("Even number");
}
else
{
Console.WriteLine("Odd number");
}
}
else
{
Console.WriteLine("Invalid Entry");
}
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter