Sunday, May 31, 2015

Parallel Array in C++

In this article I would like to share with you a program that I wrote a long time ago in C++ to demonstrate the concepts of parallel array. According to Wikipedia.org, a group of parallel arrays is a data structure for representing arrays of records. It keeps a separate, homogeneous array for each field of the record, each having the same number of elements. Then, objects located at the same index in each array are implicitly the fields of a single record. Pointers from one object to another are replaced by array indices. This contrasts with the normal approach of storing all fields of each record together in memory.

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 thru my mobile number 09173084360.

Thank you and Happy Programming.



Sample Program Output

Program Listing

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main(int argc, char *argv[])
{
 char str[][20] = {"Wally"," Skeeter"," Corky"," Jessie", "Sadie"}; 


    int val1[] = {18, 22, 12, 17, 15}; 
    int val2[] = {20 ,25 ,16 ,18 ,17 };

    cout << "\n\n";    
    cout << "\t Parallel Array in C++";
    cout << "\n\nCreated By: Mr. Jake R. Pomperada, MAED-IT";
    cout << "\n\n";    
    cout << setw(10) << "Name " << setw(12) << "Score 1" 
        << setw(10) << "Score 2";
    cout << "\n\n";    
    for(int index = 0; index < 5; index++)
{
     cout<<setw(10)<<str[index]
            <<setw(10)<<val1[index]
            <<setw(10)<<val2[index]<<endl;
}
    cout << "\n\n";    
    system("PAUSE");
    return EXIT_SUCCESS;

}


Saturday, May 30, 2015

Odd and Even Number Checker in BASH

In this article I would like to share with you a program that I wrote using BASH scripting language in Linux operating system I called this program Odd and Even Number Checker in BASH. This program is very simple and easy to understand the programs logic.

If you like my works please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippine can reach me at my mobile number at 09173084360.

Thank you very much and Happy Computing.




Sample Program Output

Program Listing

#!/bin/bash

echo -e "\n\n"
echo -e "\t\t Odd Or Even Number Checker in BASH"
echo -e "\n"
read -p  "Kindly Enter a Number :=> " value
echo -e "\n"

check=$(($value % 2))

if [ $check -eq 0 ]
   then
     echo "The number $value is an EVEN number."
   else
     echo "The number $value is an ODD number."
   fi
echo -e "\n"
echo -e "Thank you for using this program."





Addition of Two Numbers in Bash

In this article I would like to share with you one of my passion in programming writing Bash Script in Linux to automate or to make simple programs under Linux operating system. This program is very simple it will ask the user to enter two numbers and then it will display the sum of the two numbers to the user.

I am using Cgywin a linux distribution operating system that enables you run linux commands under windows it is totally free to download over the Internet here is the link https://www.cygwin.com/.

I hope you will find my simple script useful in your learning bash scripting programming in Linux operating system. 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 at this number 09173084360.

Thank you and Happy Programming.




Sample Program Output


Program Listing

#!/bin/bash

echo -e "\n\n"
echo -e "\t\t Addition of Two Numbers"
echo -e "\n"
read -p  "Enter two numbers : " a b

sum=$((a+b))
echo -e "\n"
echo "The sum of $a and $b is $sum."
echo -e "\n"
echo -e "Thank you for using this program."







Odd and Even Number Checker in JQuery

A program that I wrote using JQuery to check if the number given by the user is odd or even number I also included data validation.  I hope anyone will be benefit in this simple program.

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







Sample Program Output

Program Listing 

<html>
<title> Odd or Even Number Checker in JQuery</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> 

    <script>
    $(document).ready(function(){

    function check_even_numbers(val)
    {
     return (val%2 == 0);
     }

    $("#number").focus();
    
    $("#check").click(function(){
        
        var item_no1 = $("#number").val();
      
    
        if (item_no1==0) {
            alert("Text field cannot be empty.");
            $("#number").focus();
        }
  
        else  if (/^[a-zA-Z0-9- ]*$/.test(item_no1) == false) {

          alert('Sorry it Contains Illegal Characters.');
          $("#number").focus();    
    }    
  
        else if (isNaN(item_no1))
        {
           alert("It is not a number but a letter(s) or alphabets.");
            $("#number").focus();    
            }
        
    else if (check_even_numbers(item_no1)) {              
                
      $('.display').html(item_no1 + " is an Even Number.");
    }
   else {
        $('.display').html(item_no1 + " is an Odd Number.");        
    }
});

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

   $("#clear").click(function(){
          
           $(".display").html("");    
           $("#number").val(""); 
           $("#number").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> Odd and Even Number Checker in JQuery </h2>
    <hr size="3" color="red">
<br><br>
Kindly enter a number :
<input type="text" id="number"  name="number" maxlength="5" size="5">
<br><br>
<button id="check" type="button" title="Click here to find if the number is odd or even ."> Check Number </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>


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");
   }
}