Saturday, May 30, 2015

Addition of Five Numbers Using JQuery with Data Validation

A simple program that I wrote using JQuery that will ask the user to enter five number with data validation that I include in this program. I hope you will find this simple program useful in learning how to program in JQuery.

If you have some questions please send me at email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines can reach me in this number 09173084360.

Thank you very much and Happy Computing.





Sample Program Output

Program Listing

<html>
<title> Additon of Five Numbers in JQuery</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 
<script>
$(document).ready(function(){
    
    // auto text field focus upon loading of our
    // webpage
    
    $("#item1").focus();
    
    // function to add all the five values in our text field
    
    $("#sum").click(function(){
        
        var sum = 0;               
    
        var item_no1 = $("#item1").val();
        var item_no2 = $("#item2").val();
        var item_no3 = $("#item3").val();
        var item_no4 = $("#item4").val();
        var item_no5 = $("#item5").val();
    
    // text field validation conditions checks if the text field
   //  does not have a value to sum up
        if (item_no1==0) {
            alert("Item No. 1 Cannot be empty.");
            $("#item1").focus();
        }
  
        else  if (/^[a-zA-Z0-9- ]*$/.test(item_no1) == false) {

          alert('Value in Item No. 1 Contains illegal Characters.');
          $("#item1").focus();    
    }    
  
        else if (isNaN(item_no1))
        {
           alert("Value in Item No. 1 is not a number but a letter.");
          $("#item1").focus();    
            }
        
    else if (item_no2==0) {
            alert("Item No. 2 Cannot be empty.");
            $("#item2").focus();
           }
  else  if (/^[a-zA-Z0-9- ]*$/.test(item_no1) == false) {
          alert('Value in Item No. 2 Contains illegal Characters.');
          $("#item2").focus();    
    }    
      
    else if (isNaN(item_no2))
         {
             alert("Value in Item No. 2 is not a number but a letter.");
            $("#item2").focus();    
            }    
    else if (item_no3==0) {
            alert("Item No. 3 Cannot be empty.");
            $("#item3").focus();
           }
    
     else  if (/^[a-zA-Z0-9- ]*$/.test(item_no3) == false) {

          alert('Value in Item No. 3 Contains illegal Characters.');
          $("#item3").focus();    
    }    
          
    else if (isNaN(item_no3))
         {
             alert("Value in Item No. 3 is not a number but a letter.");
            $("#item3").focus();    
            }        
    else if (item_no4==0) {
            alert("Item No. 4 Cannot be empty.");
            $("#item4").focus();
           }
   else  if (/^[a-zA-Z0-9- ]*$/.test(item_no4) == false) {

          alert('Value in Item No. 4 Contains illegal Characters.');
          $("#item4").focus();    
    }        
    else if (isNaN(item_no4))
         {
             alert("Value in Item No. 4 is not a number but a letter.");
            $("#item4").focus();    
            }        
    else if (item_no5==0) {
            alert("Item No. 5 Cannot be empty.");
            $("#item5").focus();
           }
    else  if (/^[a-zA-Z0-9- ]*$/.test(item_no5) == false) {

          alert('Value in Item No. 5 Contains illegal Characters.');
          $("#item5").focus();    
    }            
    else if (isNaN(item_no5))
         {
          alert("Value in Item No. 5 is not a number but a letter.");
            $("#item5").focus();    
            }        
    else {              
        $(".total_sum").each(function() {             
            sum+= Number($(this).val());         
        });
        
      $('.display').html("The total sum is " + sum + ".");
    }

});

// function to clear all the content of the text field

   $("#clear").click(function(){
          
         $(".total_sum").each(function() {             
            ($(this).val(""));         
           $(".display").html("");    
           $("#item1").focus();
         });
            
            
    });

});

</script>

<style>

body {  
        background:lightgreen;
        color: blue ;
        font-family:arial;
        font-weight:bold;
        size:12;
     }
</style>


</head>
<body>
    <hr size="3" color="red">
<h2> Addition of Five Numbers in JQuery </h2>
    <hr size="3" color="red">
<br><br>
Enter Item No. 1 :
<input type="text" id="item1" class="total_sum" name="item1" maxlength="5" size="5">
<br>
Enter Item No. 2 :
<input type="text" id="item2" class="total_sum" name="item2" maxlength="5" size="5">
<br>
Enter Item No. 3 :
<input type="text" id="item3" class="total_sum" name="item3" maxlength="5" size="5">
<br>
Enter Item No. 4 :
<input type="text" id="item4" class="total_sum" name="item4" maxlength="5" size="5">
<br>
Enter Item No. 5 :
<input type="text" id="item5" class="total_sum" name="item5" maxlength="5" size="5">
<br><br>
<button id="sum" type="button" title="Click here to find the sum of the five numbers."> COMPUTE </button>
&nbsp;&nbsp;&nbsp;
<button id="clear" type="button" title="Click clear text box"> CLEAR </button>
<br><br><br>
<div class="display"></div>
</body>
</html>


Wednesday, May 27, 2015

Greeter Program in JQuery

In this article I would like to share with you a sample program that I wrote using JQuery I called this program Greeter Program what does the program will do is to ask the user to enter the first name and last name of the user and then our program will greet the user. It teaches the user how to interact with HTML and JQuery using forms and buttons.

If you have some questions feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com. People here in the Philippines who would like to contact me can reach me at my mobile  number 09173084360.

Thank you very much and God Bless.





Sample Output of the Program



Program Listing

<html>

<head>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>

</script>

<script>

 var txt=  $("#fname").val();

$(document).ready(function(){


$("#greet").click(function(){
   

    var f_name = $("#fname").val();
    var l_name = $("#lname").val();

    if(f_name==0) {
      alert("First Name cannot be empty");
      $(this).focus();
     }

  else if(l_name==0) {
      alert("Last Name cannot be empty");
      $(this).focus();
     }
   

  else {
    $('.display').html("Hello  " + f_name + " " + l_name + " How are you? ");

    
  }
   
   });


$("#clear").click(function(){
   
    var f_name = $("#fname").val(" ");
    var l_name = $("#lname").val(" ");
    $('.display').html(" ");    
    f_name.focus();
    });


});

</script>

<style>

body {  
        background:lightgreen;
        color: red;
        font-family:arial;
        font-weight:bold;
        size:12;
     }
</style>


</head>
<body>

Enter your First Name :
<input type="text" id="fname" name="fname" maxlength="20">
<br><br>
Enter your Last Name :
<input type="text" id="lname" name="fname" maxlength="20">
<br><br>
<button id="greet" type="button" title="Click here to display me"> Greet Me </button>
&nbsp;&nbsp;&nbsp;

<button id="clear" type="button" title="Click clear text box"> Clear Me </button>
<br><br><br>
<div class="display"></div>

</body>

</html>



Sunday, May 24, 2015

Count Capital and Small Letters in C

In this article I would like to share with you a simple string manipulation program that I wrote using C programming language I called this program count the number of capital and small letters in c. What the program will do is to ask the user to enter a word or sentence afterwards our program will count the number of occurrence of capital and small letters in a given word or sentence by our end user. The program is very simple it users while loop statement, pointers and one dimensional array to solve the problem.

If you ask me what type of C compiler that I am using in this program I am using Dev C++ that run in CodeBlocks text editor all this compiler can download free from charge over the Internet.

I hope you will find my work useful and beneficial in your learning how to program using C programming language. If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. You can reach me at my mobile number here in the Philippines at 09173084360.

Thank you very much and God Bless.


Sample Program Output

Program Listing


#include <stdio.h>
#include <stdlib.h>

char count_captial_small(char *y)
{

 int upper_case_letters = 0, lower_case_letters = 0,counter=0;
   counter = 0;
   while (y[counter] != '\0') {
      if (y[counter] >= 'A' && y[counter] <= 'Z')
         upper_case_letters++;
      if (y[counter] >= 'a' && y[counter] <= 'z')
         lower_case_letters++;
    counter++;
   }
   printf("\n\n");
   printf("\t ===== DISPLAY RESULT =====");
   printf("\n\n");
   printf("\nNumber of Uppercase Letters ===> %d.", upper_case_letters);
   printf("\nNumber of Lowercase Letters ===> %d.", lower_case_letters);
   printf("\n\n");
   printf("\t Thank you for this program.");
   printf("\n\n");
}

int main() {
   char ch[255];
   printf("\tCount Capital and Small Letters in C");
   printf("\n\n");
   printf("\nKindly enter a Word or a Sentence :=> ");
   gets(ch);
   count_captial_small(ch);
   return (0);
}



Sunday, May 17, 2015

Count Capital and Small Letters in Java

While learning Java programming I came up with a problem how to count the number of occurrence of capital and small letters in a given sentence or a phrase. In this sample program I use Eclipse IDE for Java that I found very easy to use. Our program will first ask the user to enter a sentence and then our program will count how many time the capital  and small letters occurs in a given sentence.

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

People here in the Philippines can reach me in this number 09173084360.

Thank you and God Bless.



Sample Program Output

Program Listing

package Capital;

import java.util.Scanner;

public class capital {
public static void main(String[] args)
   {
       char ch;
       int uppercase=0,lowercase=0;
       Scanner scan = new Scanner(System.in);
       System.out.println("\n");
       System.out.print("Count Capital and Small Letters");
       System.out.println("\n");
     System.out.print("Please Enter a Sentence :=> ");
       String str = scan.nextLine();
       for(int i=0;i<str.length();i++)
       {
           ch = str.charAt(i);
           int asciivalue = (int)ch;
           if(asciivalue >=65 && asciivalue <=90){
               uppercase++;
           }
           else if(asciivalue >=97 && asciivalue <=122){
               lowercase++;
           }
       }
       System.out.print("======= DISPLAY RESULT ========");
       System.out.print("\n\n");
       System.out.println("Number of Lowercase letter(s) :=> " + lowercase + ".");
       System.out.println("Number of Uppercase letter(s) :=> " + uppercase + ".");
       System.out.print("\n\n");
       System.out.print("\t Thank You For Using This Program");
   }
}



Product of Two Numbers in Java Using Scanner Library

In this article I would like to share with you a very simple program that I wrote in Java I called this program Product of Two Numbers in Java Using Scanner Library. I am just a beginner in terms of using Eclipse Java IDE text editor while I'm learning how to create a project I just wrote this very simple program that will ask the user to enter two numbers and then it will display the product of the two numbers to the user.

I find the eclipse ide editor easy to use and user friendly in a sense it display a command while you are type your code it is called intellisense function that can be found in Microsoft Visual Studio.

I hope you will my work useful and learning Java programming. If you have some questions feel free to send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me you can text or call me at this number 09173084360.

Thank you very much and God Bless.



Sample Program Output

Program Listing

package demo;

import java.util.Scanner;

public class Demo {

 public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Product of Two Numbers");
System.out.print(" Enter first value : ");
int val1 = scan.nextInt();
System.out.print(" Enter second value : ");
int val2 = scan.nextInt();
int product = val1 * val2;
System.out.print("The product of "+ val1  + " and " 
+ val2 + " is " + product + ".");
     } 


}








Saturday, May 16, 2015

Area of a Circle Using AngularJS

In this article I wrote a very simple application using AngularJS as our Javascript Framework that will solve the area of a circle by asking the user to enter the radius of the circle.  The code is very simple and straight forward. I am still a beginner in AngularJS programming as this moment I find it very easy to write and test our sample program.


I hope you will find our program useful in learning how to program using AngularJS one of the most popular Javascript Framework in our community right now. If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me can reach me in this mobile number 09173084460.

Thank you very much and God Bless us all.






Sample Program Output


Complete Program Listing

<html>
<head> 
<title> Area of the Circle in AngularJS </title>
</head>
<style>
p {
   color:blue;
   font-family: "arial";
   font-style: bold;
   font-size: 18px;
  }
  
h3{
   color:red;
   font-family: "arial";
   font-style: bold;
   font-size: 20px;
  }
  
 input[type='text'] 
   { 
   color:blue;
   font-family: "arial";
   font-size: 18px;
   font-style: bold;
   }
 </style>
<script type="text/javascript" src="angular.js"></script>
<body bgcolor="lightgreen">
<br><br>
<h3>Area of the Circle in AngularJS</h3>
<div ng-app="">
    <p>Enter the radius of circle:
        <input type="text" ng-model="radius" maxlength="5" size="3"/>
    </p><br>
    <p>The radius of the circle is {{radius}} its area is {{ radius * radius * 3.14159}}. m&#178</p>
<p> The circumference of the circle is {{ 2 * radius * 3.14159}}. m </p>
</div>.
</body>
</html>




Sunday, May 10, 2015

Addition of Three Numbers in AngularJS

In this article I would like to share with you a sample program that will add the sum of three numbers using AngularJS as our Javascript Framework. What does the program will do is very simple it will ask the user to enter three number and our program will automatically will sum up the values of the three numbers provided by our user.

If you like my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me can call and text me in this number 09173084360.

Thank you very much and God Bless.



Sample Program Output


Program Listing


<html>
<head> 
<title> Addition of Three Numbers in AngularJS </title>
</head>
<style>
p,h3 {
   color:blue;
   font-family: "arial";
   font-style: bold;
   size: 16;
  };
 </style>
<script type="text/javascript" src="angular.js"></script>
<body bgcolor="lightgreen">
<br><br>
<h3>Addition of Three Numbers in AngularJS</h3>
<div ng-app="">
    <p>First Number:
        <input type="text" ng-model="a" placeholder="enter a number" />
    </p>
    <p>Second Number:
        <input type="text" ng-model="b" placeholder="enter a number"/>
    </p>
  <p>Third Number:
        <input type="text" ng-model="c" placeholder="enter a number" />
    </p><br>
    <p>The total sum of {{a}}, {{b}} and {{c}} is {{ a -- b -- c }}.</p>
</div>
</body>
</html>


Sunday, May 3, 2015

Display Record From Text Area in PHP and MySQL

In this article I would like to share with you a program that I wrote in PHP and MySQL that will display the record from text area. This code is very useful is you are trying to create a news or blog website that will save news articles that are very long. I try to make the code much easier to understand by beginners in PHP and MySQL programming.


If you like my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me can call and text me in this number 09173084360.

Thank you very much and God Bless.



Sample Screen Shoot



Saturday, May 2, 2015

Factorial of Numbers Using Recursion Pointers in C++

Recursion is one of the most common method that is being used in programming to solve a problem for example factorial of numbers in C++. In this article I will show you how to solve factorial of number using recursion with pointers in C++. The code is very straight forward it uses functions to accomplish the result. I hope you will find my work useful in your study of C++ programming.

If you like my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me can call and text me in this number 09173084360.

Thank you very much and God Bless.



Sample Output


Program Listing


#include <iostream>

using namespace std;

int factorial (int num)
{
 if (num==1)
  return 1;
 return factorial(num-1)*num;
}

main() {
    int value=0;
    int *p;
    cout << "\t Recursion using Pointers";
    cout << "\n\n";
    cout << "Enter a Number :=> ";
    cin >> value;
    p = &value;
    cout << "\n";
    cout <<"The factorial value of " << value
        << " is " << factorial(value) << ".";
    cout << "\n\n";
    system("pause");
}



Bubble Sort in Descending Order Using Pointers in C++

In this article I would like to share with you a bubble sort program that I wrote in C++ that uses pointers as its data structure. What does our program will do is to as the user how many numbers to be sorted using Bubble Sort sorting algorithm. It will display the original arrangement of numbers and after which it will display the sorted numbers in descending order.


If you like my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me can call and text me in this number 09173084360.

Thank you very much and God Bless.




Sample Program Output


Program Listing


#include <cstdlib>
#include <iostream>

using namespace std;

int compare(int, int);
void sort(int[], const int);
void swap(int *, int *);

int compare(int x, int y)
{
     return(x < y);
}

void swap(int *x, int *y)
{
     int temp;
     temp = *x;
     *x = *y;
     *y = temp;
}

void sort(int table[], const int n)
{
     for(int i = 0; i < n; i++)
     {
          for(int j = 0; j < n-1; j++)
          {
               if(compare(table[j], table[j+1]))
                    swap(&table[j], &table[j+1]);
          }
     }
}

int quantity;
int* tab;

int main(int argc, char *argv[])
{
    cout << "\t\tBUBBLE SORT IN DESCENDING ORDER USING POINTERS";
    cout << "\n\n\t\t Created By: Mr. Jake R. Pomperada, MAED-IT";
    cout << "\n\n";   
    cout << "How Many Items :=> ";
cin >> quantity;
tab = new int [quantity];
cout << "Input numbers: \n\n";
for (int i = 0; i < quantity; i++)
{
    int x = i;
    cout << "#" << ++x << ": ";
    cin >> tab[i];
}

cout << "\nBefore sorting: ";
for (int i = 0; i < quantity; i++)
{
     cout << tab[i] << " ";
}

cout << "\nAfter sorting: ";
sort(tab, quantity);
for(int i = 0; i < quantity; i++)
{
     cout << tab[i] << " ";
}
 cout << "\n\n";
    system("PAUSE");
    return EXIT_SUCCESS;
}












Friday, April 10, 2015

Product of Two Numbers Using Jquery

A simple program that I wrote using JQuery that will find the product of two numbers given by our user. The code is very easy to understand and use you will learn how to use button which interacts with JQuery.

If you like my work please send me an email at jakerpomperada@gmail.com andjakerpomperada@yahoo.com.

People here in the Philippines who wish to contact me can call and text me in this number 09173084360.

Thank you very much and God Bless.




                            Sample Program Output


Program Listing

<!-- Product of Two Numbers Using JQuery -->
<!-- April 10, 2015    Friday   --->
<!-- Written By: Mr. Jake R. Pomperada, MAED-IT -->
<!-- Tools : HTML,CSS and JQuery -->
<html>
<head>
<title> 
Product of Two Numbers Using JQuery 
</title>
</head>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
label{
    display: table-cell;
    text-align: justify;
}
input {
  display: table-cell;
}
div.row{
    display:table-row;
}  
</style>
<script type="text/javascript" src="jquery.js"></script>
</head>
<body style='background-color:lightgreen'>
<div style='width:1100px;margin:auto'>
  <br> <h1 align="center">Product of Two Numbers in JQuery</h2>
<font face="arial" size='5'>
<div class="row"><label>    Enter First Value  </label> &nbsp;&nbsp;
<input style="font-size:20px; font-family:arial; color:magenta" type="text" name="val1"
  id="val1" autofocus maxlength="10" size="5">  </div>
  <div class="row"><label>  Enter Second Value </label> &nbsp;&nbsp;
<input style="font-size:20px; font-family:arial; color:magenta" type="text" name="val2"
  id="val2" autofocus maxlength="10" size="5"> </div>
</font><br>
<br> <input id="button1" type="button" name="button"
 title="Click here to find the product of two numbers." value="Find Product">
<input id="button2" type="button" name="button" 
title="Click here to clear the text boxes." value="Clear">
 <br><br><br>
<div id="display" style="height: 50px; width: 100%;"></div>
<script type="text/javascript">
 $(document).ready(function(){
    $('#button1').click(function(){
          a =document.getElementById("val1").value;
 b =document.getElementById("val2").value;
 product = a*b;
 message = "The product of " + a + " and " + b + " is " + product + ".";
      display.innerHTML= message;
   
    });
$('#button2').click(function(){
          document.getElementById("val1").value="";
 document.getElementById("val2").value="";
 display.innerHTML="";
         document.getElementById("val1").focus();
  });
});
 </script>
</body>
</html>