Monday, March 30, 2015

Miles To Kilometers Converter in Javascript

In this article I would like to share with you another conversion program that I wrote using Javascript as my programming language I called this program Miles To Kilometers Converter. What does the program will do is to ask the user how many miles to be converted into kilometers equivalent. I also added some error handling codes which allows us to filter invalid values from our user of the program.


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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360






Program Listing

<html>
<title>Miles To Kilometer Converter </title>
<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 language="JavaScript">
function kilomet()
  {
   
   var miles =document.getElementById("value1").value;
      if (isNaN(miles)|| (miles <0 ) || (miles =="")){
          alert (" Enter a valid number! Try Again... ");
          document.getElementById("value1").value = "";
          document.getElementById("value1").focus();
      }
else  { 
 solve= (miles * 1.60934);
 document.getElementById("kilo").value= solve.toFixed(5)
 document.getElementById("miles").value= miles;
    }
}

    function clear_me() {
    document.getElementById("kilo").value="";
document.getElementById("value1").value="";
document.getElementById("value1").focus();
}


  </script>
<body style='background-color:lightgreen'>
<div style='width:1100px;margin:auto'>
  <br> <h1 align="center">Miles To Kilometer Converter</h2>
  <br>
<div class="row"><label> How many miles </label>  <input type="text" name="value1"  id="value1"  value=""  size=5/> </div>
 <br><button onclick="kilomet();" 
 title="Click here to find equivalent of miles to kilometers.">
 Convert To Kilometers</button> 
 <button onclick="clear_me();" title="Click here to clear text fields.">
Clear</button> 
 <br><br><br>
 <div class="row"><label>  The  <input id="miles"  size="5" readonly> 
 miles is equivalent to <input id="kilo"  size="5" readonly> in kilometers. </label>   <br> </div>
  
<br> 
  </body>
</html>

Thursday, March 26, 2015

Area and Circumference of the Circle Using JavaScript

In this article I would like to share with you a sample program to solve the area and circumference of the circle in a given value by the user using Javascript as my programming language. What is good about this program I included a function to check if the value given by the user is numeric or not and a button that enables the user to clear the text box.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360






Program Listing

<html>
<title> Area and Circumference of the Circle Solver </title>
<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 language="JavaScript">
   function solve_circle(){
   var radius =document.getElementById("value1").value;
      if (isNaN(radius)|| (radius <0 ) || (radius =="")){
          alert (" Enter a valid number! Try Again... ");
          document.getElementById("value1").value = "";
          document.getElementById("value1").focus();
      }
else  {
 solve= (radius * radius * Math.PI);
      circumference =   (2 * radius * Math.PI);
      document.getElementById("circle_area").value= solve.toFixed(2)
document.getElementById("circum_area").value= circumference.toFixed(2)
     }
}
    function clear_me() {
    document.getElementById("circle_area").value="";
document.getElementById("circum_area").value="";
document.getElementById("value1").value="";
document.getElementById("value1").focus();
}
</script>
<body style='background-color:lightgreen'>
<div style='width:1100px;margin:auto'>
  <br> <h1 align="center"> Area and Circumference of the Circle Solver</h2>
  <br>
<div class="row"><label> Enter a Number :</label>  <input type="text" name="value1"  id="value1"  value=""  size=5/> </div>
 <br><button onclick="solve_circle();" 
 title="Click here to find the area and circumference of the circle.">
 Find Area of the Circle</button> 
 <button onclick="clear_me();" title="Click here to clear text fields.">
Clear</button> 
 <br><br><br>
 <div class="row"><label>  The area of the circle is </label>  <input id="circle_area"  size="10" readonly> <br> </div>
  <div class="row"><label> The circumference of the circle is </label>  <input id="circum_area"  size="10" readonly></div> <br>
<br> 
  </body>

</html>

Tuesday, March 24, 2015

Feet To Meters Solver in PHP

In this simple program it will ask the user to enter a value in feet and then it will convert to its meters equivalent using PHP as our programming language. I also added validation function to check if the text field is empty or not and if the user give not a numeric value it will display an error message to the user informing that the value must be numeric in nature.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



Program Listing

<html>
<title> FEET TO METERS SOLVER </title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);

$values = $_POST['value'];

 // function to solve convert feet to meters

 function feet_to_meters($variable) {
           return($variable * 0.3048);
}

if(isset($_POST['check'])) {

     if (ctype_alpha($values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
  $values="";
 }
 
else if(preg_match('#[^a-zA-Z0-9]#', $values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
        $values="";
      
}

    else  if ($values=="") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a integer value.');";
  echo "</script>";
  $values="";
           }
else { 
      $title = "The equivalent value of ".$values." Feet(s) is " 
          .feet_to_meters($values)." Meter(s).";
       }  
   }  

if(isset($_POST['clear'])) {
  $values=" "; 
  $title=" ";
  
}

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> FEET TO METERS SOLVER </h2>
  <br>
<form action="" method="post">
 Enter a Number : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=20/>
   <input type="submit" name="check" value="Convert To Meters" 
  title="Click here to convert to meters equivalent."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br> 
<?php 
echo $title;
 ?>
  </body>
</html>


Monday, March 23, 2015

Diamond Pattern in PHP

In this article I would like to share with you a code that I wrote using PHP to display an image of an diamond using asterisk. The code is very short and easy to understand I'm just using for loop statement to create the diamond image.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360





Program Listing

<html>
<title> Diamond Pattern </title>
<body bgcolor="lightgreen">
<h1><font face="comic sans ms" color="red"> Diamond Pattern in PHP </face></h1>
<?php

$a=6; $b=0; $c=0; $space = 1;
  $space = $a - 1;
  for ($c = 1; $c <= $a; $c++)
  {
    for ($b = 1; $b <= $space; $b++)
    echo " &nbsp;&nbsp;&nbsp;   ";

     for ($b = 1; $b <= 2*$c-1; $b++)
     printf("<font size='6' color='red'> * </font> ");
     printf("<br>");
     $space=$space-1;
  }
  $space = 1;
  for ($c = 1; $c <= $a - 1; $c++)
  {
    for ($b = 1; $b <= $space; $b++){
     echo " &nbsp;&nbsp;&nbsp;  ";
     }
    $space++;
    for ($b = 1 ; $b <= 2*($a-$c)-1; $b++) {
      printf("<font size='6' color='red'> * </font> ");
 }
     echo "<br>";
  }
  ?>
 </body>
 </html>
  

Saturday, March 21, 2015

Inverted Triangle Pattern in c++

In this article I would like to share with you a sample program that I wrote using C++ as my programming language that will display an inverted triangle pattern image. For this code I'm using two for loop statement to achieve the pattern design of the inverted triangle.



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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360



 Program Listing
#include <iostream>
#include <stdlib.h>

using namespace std;

   int a=0, b=0, c=0;
  
void display()
{

   cout << "\t INVERTED TRIANGLE";
   cout << "\n\n";
    for(a=20;a>=1;a-=1)
    {
        for(b=20;b>a;b-=1)
        {
                cout << " ";
        }
        for(c=1;c<(a*2);c+=1)
        {
                cout << "^";
        }
        cout << "\n";
    }
        cout << "\n\n";
}

int main()
{
    display(); 
    system("pause");
  }
 

Friday, March 20, 2015

Remove Vowel in Java


In this article I would like to share with you a sample program that will remove vowels in a given string or sentence of our user I called this program remove vowels written in Java as our programming language. What does our program will do is to ask the user to enter any string or sentence then our program will remove or delete vowels that can be found in a given string or sentence. Regardless if the string is lower case or upper case format. I hope you will find my work useful in your learning string manipulation in Java.


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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Program Listing

import java.util.Scanner;

public class remove {
  static Scanner input = new Scanner(System.in);

  public static void main(String[] args) {

     char reply;
    do
      {
      System.out.print("\n");
 System.out.println("==============================================");
 System.out.println("||    <<<  REMOVE VOWEL PROGRAM     >>>     ||");
 System.out.println("==============================================");
      System.out.print("\n");
      System.out.print("Enter a Word or a Sentence :=>  ");
      String str = input.nextLine();
      String original_string = str;

    for (int a = 0; a < str.length(); a++) {
      char val = str.toUpperCase().charAt(a);
      if ((val == 'A') || (val == 'E')  || (val == 'I')
          || (val == 'O') || (val == 'U')) {
        String first = str.substring(0, a);
        String second = str.substring(a + 1);
        str = first + " " + second;

      }
    }
    System.out.println("\n");
    System.out.println("The Original String     :=> " + original_string + ".");
    System.out.println("The Remove Vowel String :=> "  +str+".");
    System.out.println("\n");
System.out.print("Do you Want To Continue (Y/N) :=> ");
     reply=input.next().toUpperCase().charAt(0);
    } while(reply=='Y');
    System.out.println("\n");
    System.out.println("\t ===== END OF PROGRAM ======");
    System.out.println("\n");
 }
}


Remove Vowels Program in PHP


In this article I would like to share with you a sample program that will remove vowels in a given string or sentence of our user I called this program remove vowels written in PHP as our programming language. What does our program will do is to ask the user to enter any string or sentence then our program will remove or delete vowels that can be found in a given string or sentence. Regardless if the string is lower case or upper case format. I hope you will find my work useful in your learning string manipulation in PHP.


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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Program Listing

<html>
<title> Remove Vowels Program</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>


<?php

error_reporting(0);
$values = $_POST['value'];

$values2 = $values;
if(isset($_POST['check'])) {

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a sentence.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }
 
 if ($values != " ") {
 
   $total_vowels = 0; $total_consonants=0;

      $vowels = Array('a','e','i','o','u','A','E','I','O','U');
      $vowels = Array('a','e','i','o','u','A','E','I','O','U');

   $results .=  "========================<br> ";  
   $results .=  "==== DISPLAY RESULT ====<br> ";
   $results .=  "========================<br>";  
   $results .=  "<br>";
   $results .= "The word or sentence is   :=>   " .$values."<br><br>";
   
for ($b=0;$b<strlen($values);$b++)
{
    for ($a = 0;$a<10;$a++)
        if ($values[$b] == $vowels[$a])
        {
            $values[$b]=" ";
            break;
        }
  }
   $results .= "Remove Vowel Sentence  :=>  " .$values."<br>";   
   
   }
  
    }
  
   
if(isset($_POST['clear'])) {
  $values2=" "; 
  $results= " ";
  
}

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">REMOVE VOWELS PROGRAM </h2>
  <br>
<form action="" method="post">
 Enter a Word Or Sentence : <input type="text" name="value"    value="<?php echo $values2; ?>" 
 autofocus  size=60/>
 <br><br>
   <input type="submit" name="check" value="Remove Vowels" 
  title="Click here to remove vowels in a given sentence."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>
<br>
<?php 
echo $results;
 ?>
  </body>
</html>


Remove Vowels Program in C++

In this article I would like to share with you a sample program that will remove vowels in a given string or sentence of our user I called this program remove vowels written in C++. What does our program will do is to ask the user to enter any string or sentence then our program will remove or delete vowels that can be found in a given string or sentence. Regardless if the string is lower case or upper case format. I hope you will find my work useful in your learning string manipulation in C++.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Sample Program Output


Program Listing

#include <iostream>
#include <ctype.h>

using namespace std;


int main() {
    string text_me;
    char reply;
   do {
    cout << "\n\n";
    cout << "\t========================\n";
    cout << "\t REMOVE VOWELS PROGRAM\n ";
    cout << "\t========================\n";
    cout << "\n";
cout << "\tEnter a String :=> ";
getline(cin,text_me);
cout << "\n\n";
    cout <<"\tORIGINAL TEXT :=> " << text_me;

for (int i=0;toupper(text_me[i])!='\0';i++)
     {
if (toupper(text_me[i])==toupper('a')
            || toupper(text_me[i])==toupper('e')
            || toupper(text_me[i])==toupper('i')
            || toupper(text_me[i])==toupper('o')
            || toupper(text_me[i])==toupper('u'))
         {
text_me[i]=' ';
}
      }
cout << "\n\n";
cout <<"\tVOWEL REMOVE TEXT :=> " << text_me;
cout << "\n\n";
cout << "\t Do You Want To Continue Y/N :=> ";
cin >> reply;
} while(toupper(reply)=='Y');
cout << "\n\n";
cout << "\t === THANK YOU FOR USING THIS PROGRAM ===";
cout << "\n\n";
return 0;
}


Thursday, March 19, 2015

Student Address Book Using PDO in PHP

As a software engineer my main forte is web design and development particularly using PHP in the past I used procedural programming in PHP until now is some small not critical projects I'm still using this type of programming paradigm but when I try to learn how to program using PHP frameworks like Codeigniter, Zend, CakePHP it gives me a headache because I don't know object oriented programming in PHP. In order for me to overcome my weakness I study PDO of PHP Data Objects that gives me an edge and knowledge how to work on those PHP frameworks with some confidence. 

PHP Data Objects now a days is very hard to ignore primarily because all PHP Frameworks works with the concepts of object oriented programming paradigm and Design Patterns. Using prepared statement in PDO help us also to overcome SQL injection attacks in our websites. In this article I would like to share with you a simple program that I wrote using PHP Data Object to add, edit, delete and view student records in our address book. The code is very simple yet enable us to understand the inner working of PDO interaction with our MySQL database.  I hope you will find my work useful and beneficial in your learning in PHP programming and development.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360




Wednesday, March 18, 2015

Count the number of years and weeks in a given days in Java


In this article I would like to share with you a sample program that I wrote using JAVA I called this program Count Years or Weeks  in a given days Using JAVA. The code is very simple by the use of simple formulas I hope you will find my work useful in your programming assignments and projects in JAVA.

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

People here in the Philippines who wish to contact me can reach me at my mobile number 09173084360





SAMPLE OUTPUT OF OUR PROGRAM


Program Listing

import java.util.Scanner;


class year_count
{

  public static int solve_it(int days)
   {
 int years=0,solve=0,weeks=0;
 years = days/365;
 solve=days-(years*365);
 weeks=days/7;
      solve=days-(weeks*7);
      System.out.println(years + " Year(s) or " + weeks + " Week(s).");
      return 0;
    }

public static void main(String args[])
{
  Scanner in = new Scanner(System.in);
   char a;
do
 {

 int no_days=0;

 System.out.print("\n");
 System.out.println("=============================================================");
 System.out.println("||   <<< COUNT NO. OF YEARS OR WEEKS IN A GIVEN DAYS >>>   ||");
 System.out.println("=============================================================");
     System.out.print("\n");
     System.out.print("Enter Number of Days :=> ");
          no_days = in.nextInt();

     System.out.println("\n");
 System.out.println("=======================");
 System.out.println("||  DISPLAY RESULT   ||");
 System.out.println("=======================");
 System.out.println("\n");
          solve_it(no_days);


          System.out.println("\n\n");
          System.out.print("Do you Want To Continue (Y/N) :=> ");
           a=in.next().charAt(0);

   } while(a=='Y'|| a=='y');
          System.out.println("\n");
          System.out.println("\t ===== END OF PROGRAM ======");
         System.out.println("\n");
}
}