//************************************** // Name: Odd and Even Number Checker in C# // Description:A simple program that I wrote using C# to check if the given number by our user is Odd or Even numbers. Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360. // By: Jake R. Pomperada // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //************************************** // Odd and Even Number Checker in C# // September 11, 2016 Sunday // Written By: Mr. Jake R. Pomperada, MAED-IT using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public static bool IsEven(int value) { return value % 2 == 0; } private void button1_Click(object sender, EventArgs e) { int number = 0; if (!int.TryParse(textBox1.Text, out number)) { MessageBox.Show("I need just a number in the textbox."); textBox1.Text = ""; label2.Text = ""; textBox1.Focus(); } else if (IsEven(number)) { label2.Text = "The Number " + number + " is an Even Number."; } else { label2.Text = "The Number " + number+ " is an Odd Number."; } } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; label2.Text = ""; textBox1.Focus(); } } }