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



Tuesday, March 17, 2015

Count Years or Weeks in a given days in C++

In this article I would like to share with you a sample program that I wrote using C++ I called this program Count Years or Weeks  in a given days Using C++. 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 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



Program Lisitng

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

using namespace std;

int main()
{

 int years=0,days=0,weeks=0,solve=0;
 char reply;
 do {
 system("cls");
 cout << "\n==================================================";
 cout << "\n||  COUNT NO. OF YEARS OR WEEK IN A GIVEN DAY   ||";
 cout << "\n==================================================";
 cout << "\n\n";
 cout<<"ENTER NUMBER OF DAYS :=> ";
 cin>>days;
 years = days/365;
 solve=days-(years*365);
 weeks=days/7;
 solve=days-(weeks*7);

  cout << "\n\n";
  cout << "\n=========================";
  cout << "\n||  DISPLAY RESULTS    ||";
  cout << "\n=========================";
  cout << "\n\n";
  cout<<years << " Year(s) or " << weeks << " Week(s).";
  cout << "\n\n";
  cout << "Do you want to continue y/n :=> ";
  cin >> reply;
 } while (toupper(reply)=='Y');
  cout << "\n\n";
  cout << "======  THANK YOU FOR USING THIS PROGRAM =====";
  cout << "\n\n";
}


DOWNLOAD SOURCE CODE HERE