Friday, August 18, 2017

Palindrome Using JQuery and JavaScript

In this article I wrote a simple program to check if the given word by the user is a Palindrome or Not a Palindrome. A Palindrome word refers to a word that when we read forward and backwards the spelling is the same and it's sound also. Examples of Palindrome words are below:

  • Anna
  • Civic
  • Kayak
  • Level
  • Madam
  • Mom
  • Noon
  • Racecar
  • Radar
  • Redder
  • Refer
  • Repaper
  • Rotator
  • Rotor
  • Sagas
  • Solos
  • Stats
  • Tenet
  • Wow
I wrote the code using JQuery and JavaScript I hope you will like my work. Thank you very much for visiting my website.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.






Sample Program Output


Program Listing

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Palindrome Using JQuery and JavaScript</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("button").click(function(){
            var words = $("textarea").val();
var flag = true;
var  str = words.toUpperCase();
         for( var i = 0; i <= words.length-1; i++){
if( words[i] !== words[words.length - i-1]){
flag = false;  
}
}
if(flag == false){
  
output = 'The word ' + str +' is not a Palindrome!';   
}
else {
output = 'The word ' + str + ' is a Palindrome!';
}
document.getElementById("result").innerHTML = output;
        });
    });
</script>
  <style>
   body {
     font-family:arial;
font-weight:bold;
background-color: lightgreen;
size:12px;
   }
  </style>
</head>
<body>
    <br>
<h2>Palindrome Using JQuery and JavaScript</h2>
<br>
    Enter a word 
    <textarea cols="80"></textarea>
    <br><br>
    <button type="button" title="Click here to check if the given work is a Palindrome.">
Ok</button>
<br><br><br>
The result : <span id="result"></span>
</body>
</html>                                



Monday, August 14, 2017

Divide Two Numbers in Visual Basic 6

A very simple program that I wrote using Microsoft Visual Basic 6 to ask the user to give two numbers and then our program will compute the quotient of the two numbers given by our user. The code is very short and easy to understand. I hope you will learn something on this one. Thank you.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.







Sample Program Output


Program Listing

' Written By: Mr. Jake R. Pomperada, MAED-IT
' August 14, 2017
' Mandaluyong City, Metro Manila
' Visual Basic 6


Private Sub Command1_Click()
Dim solve As Integer
Dim a As Integer
Dim b As Integer

a = Val(Text1.Text)
b = Val(Text2.Text)

solve = (a / b)

Label3.Caption = "The Division of Two Numbers is " & Trim(Val(solve)) & "."
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Label3.Caption = ""
Text1.SetFocus
End Sub

Private Sub Command3_Click()
End
End Sub



Division of Two Numbers in Java Using Inner Class

In this article I would like to share with you how to create inner classes in Java. Inner Classes are very fundamental concepts in object oriented programming in Java programming it makes our code more easier to understand and secure. In this example our program will ask the user to give two numbers and our program will compute the quotient of the two numbers. The code is written using Netbeans IDE that is free to download over the I hope you will find my work useful. Thank you.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.







Sample Program Output


Program Listing

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package inner;

/**
 *
 * @author jake.r.pomperada
 */


import java.util.Scanner;

class Outer_Demo {
   int num1=0,num2=0;
   
   Scanner input = new Scanner(System.in);
   
   // inner class
   private class Inner_Demo {
      public void print() {
         System.out.print("===== Division of Two Numbers in Java Using Inner Class =====");
         System.out.print("\n\n");
         System.out.print("Enter First  Value : ");
         num1 = input.nextInt();
         System.out.print("Enter Second Value : ");
         num2 = input.nextInt();
         // perform division here
         num1/=num2;
         System.out.print("\n\n");
         System.out.println("The Division of two numbers is: "+num1 +".");
         System.out.print("\n\n");
         System.out.print("===== END OF PROGRAM =====");
         System.out.print("\n\n");
      }
   }
   
   // Accessing he inner class from the method within
   void display_Inner() {
      Inner_Demo inner = new Inner_Demo();
      inner.print();
   }
}
   
public class Inner {

   public static void main(String args[]) {
      // Instantiating the outer class 
      Outer_Demo outer = new Outer_Demo();
      
      // Accessing the display_Inner() method.
      outer.display_Inner();
   }
}

Sunday, August 6, 2017

Try and Exception Handling Demo in Java

A very simple program that I wrote as requested to me by one of our visitor of my website to show how to use exception handling and do you want to continue in Java. What does the program do is to ask the user to give a number if the number is not an integer will display an error message on the screen and it will ask the user if the user wants to continue to run the program again. I hope you will find my work useful. Thank you.

I hope you will find my work useful and beneficial. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.





Sample Program Output


Program Listing


/* Try and Exception Handling Demo in Java */
/* Author: Mr. Jake R. Pomperada, MAED-IT */
/* August 6, 2017   Sunday      2:04 PM   */
/* Mandaluyong City, Metro Manila         */
/* Philippines                            */
/* Editor : TextPAD                       */
/* Language : Java SE                     */



import java.util.*;

class test{

public static void main(String args[]){

    Scanner input= new Scanner(System.in);
    int a=0;

    char ch;

  do {

        try{
            System.out.println("\n\n");
            System.out.println("Try and Exception Handling Demo in Java");
            System.out.println("\n");
            System.out.println("Written By: Mr. Jake R. Pomperada");
            System.out.println("\n");
System.out.print("Enter a Number  : ");

            a = input.nextInt();

          System.out.println("\n");
          System.out.println("The number you just given is " + a + ".");
          System.out.println("\n");
        }catch(InputMismatchException exception){
          System.out.println("\n");
          System.out.println("Invalid Integer value. Try Again Give an Integer value");
          input.nextLine();
 }

     System.out.println("\n");
     System.out.print("\nDo you want to continue (Type y or n) : ");
     ch = input.next().charAt(0);


     } while (ch == 'Y'|| ch == 'y');

     System.out.println();
     System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
     System.out.println("\n\n");
  }

}





Thursday, August 3, 2017

Product of Two Numbers Using Classes in C++

Here is a simple code that I wrote a long time ago while I am working as a college professor in one of the University in my hometown. I was teaching C++ programming from the basics to advance topics. Below is a code the shows how to use classes to find the product of two number being provided by the user. I am using Dev C++ as my C++ compiler in writing this program and CodeBlocks as my text editor. I hope you will learn something from it. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.



Program Listing



#include <iostream>
#include <string>

using namespace std;

class multiply {
    int val1,val2;
    char reply;
    public:
    int get_data();
    void display_result(void);
};


int multiply :: get_data()
{
    while (1) {
    system("cls");
    cout << "enter two number :";
    cin >> val1>> val2;
    cout << "\n\n The Product is " << (val1*val2);
    cout << "\n\n";
    cout << "More Y Or N : ";
    cin >> reply;

    if (tolower(reply) == 'n') {
        cout << "Thanks";
        break;
    }
    }
}

void multiply :: display_result(void)
{
    int val=0;
    val = get_data();
}

main() {
    multiply numbers;

    numbers.display_result();
}



Class Age in C++

A very simple program that I wrote using classes and object oriented programming in C++ a long time ago that I would like to share to my fellow programmers around the world who visited my website. I hope you will learn from this simple program. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.



Program Listing


#include <iostream>

using namespace std;

class age {
    int ages;
    public:
     int getdata();
     void display(void);
};


int age:: getdata()
{
    cout << "Enter the age of the person : ";
    cin >> ages;
    if (ages >= 18) {
        cout <<"\n The person is Already an Adult.";
    }
    else
     {
        cout <<"\n The person is Still a Minor.";
    }

}

void age:: display(void)
{
    int value;
    value = getdata();
}


main()
{
    age start;
    start.display();
}



Odd and Even Numbers with Bubble Sort in Java

Here is the revision of my previous code that I wrote using Java as my programming language. The the program does it will accepts a series of numbers and then it will display the list of odd and even numbers. After which our program will ask the user if the user would like to sort the given series of numbers in ascending or descending order. The code uses bubble sort algorithm to sort the numbers.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

Thank you.




Sample Program Output


Program Listing


import java.util.Scanner;

class odd_even {

  public static void main(String[] args) {

 Scanner input = new Scanner(System.in);
 char ch;
 int [] values;
 values = new int[10];
 int x=0;
 System.out.print("ODD AND EVEN NUMBERS PROGRAMS VERSION 2.0");
 System.out.println("\n\n");
 System.out.print("Written By: Mr. Jake R. Pomperada ");
 System.out.println("\n\n");
  for (int a=0; a<10; a++)
  {
x=1;
x+=a;
  System.out.print("Enter value in item no. " + x + " : ");
  values[a] = input.nextInt();
}
 System.out.println();
 System.out.print("LIST OF EVEN NUMBERS");
 System.out.println();
 for (int a=0; a<10; a++)
  {
  if(values[a]%2 == 0) {
System.out.print(" " + values[a]+ " ");
}
 }
 System.out.println("\n\n");
 System.out.print("LIST OF ODD NUMBERS ");
 System.out.println();
 for (int a=0; a<10; a++)
 {
 if(values[a]%2 != 0) {
System.out.print(" " + values[a]+ " ");
}
 }
 System.out.println("\n\n");
 System.out.print("\n Sort Array Order? 1 - Ascending Order and 2 - Descending Order : ");
 ch = input.next().charAt(0);

 if (ch=='1') {
 //Sorting in ascending order using bubble sort
        bubbleSortInAscendingOrder(values);

        System.out.println("\n\n");
        System.out.print("===== ASCENDING ORDER ===== ");
        System.out.println("\n\n");
        for(int i = 0; i < values.length; i++)
        {
            System.out.print(values[i]+" ");
        }
   }

    if (ch=='2') {

     //Sorting in Decending order using bubble sort

            bubbleSortInDecendingOrder(values);

            System.out.println("\n\n");
            System.out.print("===== DECENDING ORDER ===== ");
            System.out.println("\n\n");
            for(int i = 0; i < values.length; i++)
            {
                System.out.print(values[i]+" ");
            }
   }
 System.out.println("\n\n");
 System.out.print("\t THANK YOU FOR USING THIS PROGRAM");
 System.out.println("\n\n");
 }


   //This method sorts the input array in asecnding order

     public static void bubbleSortInAscendingOrder( int numbers[])
     {
         int temp;

         for(int i = 0; i < numbers.length; i++)
         {
             for(int j = 1; j < (numbers.length -i); j++)
             {
                 //if numbers[j-1] > numbers[j], swap the elements
                 if(numbers[j-1] > numbers[j])
                 {
                     temp = numbers[j-1];
                     numbers[j-1]=numbers[j];
                     numbers[j]=temp;
                 }
             }
         }
     }


     //This method sorts the input array in decending order

     public static void bubbleSortInDecendingOrder( int numbers[])
     {
         int temp;

         for(int i = 0; i < numbers.length; i++)
         {
             for(int j = 1; j < (numbers.length -i); j++)
             {
                 //if numbers[j-1] > numbers[j], swap the elements
                 if(numbers[j-1] < numbers[j])
                 {
                     temp = numbers[j-1];
                     numbers[j-1]=numbers[j];
                     numbers[j]=temp;
                 }
             }
         }
     }


} // End of Code