Showing posts with label odd and even numbers. Show all posts
Showing posts with label odd and even numbers. Show all posts

Sunday, March 20, 2016

Odd and Even Number Checker in C#

In this sample program I wrote using Microsoft C# it will ask the user to give a number and then our program will check and determine whether the given number is odd or even.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(this.button1, "Click here to find out if number is ODD or EVEN number.");
            ToolTip1.SetToolTip(this.button2, "Click here to clear textbox.");
            label3.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int values = Convert.ToInt32(textBox1.Text);


           if (values % 2 == 0)
            {

                label3.Visible = true;
                label3.Text ="The number " + " " + values.ToString() + " is an EVEN number.";
            }
            else
            {
                label3.Visible = true;
                label3.Text = "The number " + " " + values.ToString() + " is an ODD number.";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            label3.Text = "";
            textBox1.Text = "";
            textBox1.Focus();
        }
    }
}



Monday, June 2, 2014

Odd and Even Number Checker in Python


Learning is a continues process this is true specially we are working in the field of Information Technology. A field that everyday is changing in terms of new development in technology we must able to adapt new methods how to manage information to be beneficial not only to us but also to other people.

In this article I will continue my study and sharing my sample program using Python as my programming language by this time I called this program Odd and Even Number Checker in Python. Writing programs in Python makes me realize that this programming language is easy and simple to use anyone who reads my article I encourage each of you to give Python a try in your programming projects on hand it will make your life much easier and enjoyable way to write code.

What the program will do is to ask the use to enter a number and then our program will determine whether the number that is being given by the user is odd or even number. I write a simple function in python to determine if the number is an odd or even number. Below is the function that I wrote I name it check_value with a parameter that I named number.

def check_value(number):
 if  (number%2 == 0):
    print("The number" ,number,"is an Even Number.")
 else:
   print("The number" ,number, "is an Odd Number.")
   return

I hope you will find my work useful and beneficial in your learning how to program in Python programming language.

Thank you very much.

Sample Output Of our Program


Python Integrated Programming Environment

Program Listing

# Odd and Even Number Checker
# Written By: Mr. Jake R. Pomperada, MAED-IT
# Tools : Python
# Date  : June 2, 2014 Monday

def check_value(number):
 if  (number%2 == 0):
    print("The number" ,number,"is an Even Number.")
 else:
   print("The number" ,number, "is an Odd Number.")
   return

print("\n")
print("@==================================@")
print("    ODD AND EVEN NUMBER CHECKER     ")
print("@==================================@")

complete = False
while complete == False:
 print("");
 value = int(input("Kindly Enter A Number :=> "))
 print("");
 check_value(value);
 print("")

 choice = input("Are You Finish?  Y/N: ").lower().strip()

 if choice == "y":
      complete = True
 else:
      print("")

print("\n")
print("Thank You For Using This Program.")
print("\n")