Wednesday, March 4, 2015

Photo Gallery in PHP and MySQL

In this article I would like to share with you program that is written by my friend Mr. Dave Marcellana he called his program Photo Gallery. Dave would like to share his work to us to help also other programmers understand how to work with images and text in PHP and MySQL. What does the program do is to allow our user to upload the picture of the picture and text description afterwards we have a combo box which allows us to select which photo album we want to display. In this example we can also populate the data entry from our MySQL table to our web page. I hope the work of my friend Dave we will help you a lot in understanding how to program in PHP and MySQL.

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





Decimal To Binary Converter in Java

In this short article you will learn how to write a program in Java how to convert decimal value into its binary equivalent the code is very simple and easy to understand for beginners in Java programming.

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 binary
{

  public static  int decimal_to_binary(int value)
   {

    String Binary_Number;    Binary_Number="";
     while (value != 0) {

       if (Binary_Number.length() % 5 == 0)
           Binary_Number = " " + Binary_Number;
                Binary_Number = (value % 2) + Binary_Number;

            value = value / 2;
      }
            System.out.print(Binary_Number +".");

     return 0;
     }


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

  do
    {

    int num1=0;

    System.out.print("\n");
    System.out.println("==============================================");
    System.out.println("||    <<< Decimal To Binary Converter  >>>  ||");
    System.out.println("==============================================");
       System.out.print("\n");
       System.out.print("Enter A Number :=> ");
          num1 = in.nextInt();

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

    System.out.print("The binary equivalent of " + num1 + " is ")  ;
    decimal_to_binary(num1);

          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 3, 2015

Simple Calculator in Java

In this simple and short article I would like to share with you a simple calculator that I wrote using Java as my programming language what the program will do is to ask the user to enter a simple mathematical expression for example 5 + 6 and then the user will press the enter key and it will display the result of 11. It has four basic math functions addition, subtraction, multiplication and division. My program also ask the user if the user would like to give a different value and change new operator by asking the user do you want to continue. The code is very simple primarily I'm just using a switch case statement to select what operator to be used for computation. I hope you will find my work useful and beneficial in learning how to program using Java as your programming language.

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

import java.util.Scanner;

public class calc {
    public static void main(String[] args) {
Scanner in = new Scanner(System.in);
         char operator,reply;
         do {
              System.out.print("\n");
     System.out.println("==============================================");
     System.out.println("||    <<<   SIMPLE CALCULATOR  >>>          ||");
     System.out.println("==============================================");
              System.out.print("\n");
              System.out.print("ENTER AN EXPRESSION (ex. 2 + 2) :=> ");

              double val1 = in.nextDouble();
              operator=in.next().charAt(0);
              double val2 =in.nextDouble();

            switch (operator)  {
            case '+':
               System.out.println("\n");
               System.out.println("The sum is :=> " + (val1 + val2));
                break;

            case '-':
               System.out.println("\n");
                System.out.println("The difference is :=> " + (val1 - val2));
                break;

            case '/':
                System.out.println("\n");
                System.out.println("The quotient is :=>  " + (val1 / val2));
                break;

            case '*':
                System.out.println("\n");
                System.out.println("The product is :=> " + (val1 * val2));
                break;

            default:
                System.out.println("\n");
                System.out.println("Please Try Again Sorry Wrong Operator...");

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

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


Pascal Triangle in PHP

In this short tutorial I will show you how to create a Pascal Triangle Checker in PHP. What is program will do is very simple it will ask the user to enter a number and then our program will generate the corresponding Pascal Triangle Numbers based on the given number by our user.

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

<html>
<title> Pascal Triangle Checker</title>
<style>
body { 
  font-size:25px; 
  font-family:arial;
  color:blue;
  } 
  
#banner {
  width: 750px;
  background-color: yellow;
  height: 100px;
  margin: 0 auto;
  position: inherit;
  top: 100; 
  left: 0; 
  bottom:0; 
  right: 0;
  padding: 16px 16px;
  
  border-radius: 75px;
  border: 5px solid #fba827;
}
  /* BUTTONS */

#submit {
  background: #0a7d66;
  background-image: -moz-linear-gradient(#0fb493, #0a7d66);
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #6cbb6b),color-stop(1, #0fb493));
  
  margin: 0 0 0 2px;
  padding: 15px 20px;

  border-radius: 3px 70px 70px 3px;
  -moz-border-radius: 3px 70px 70px 3px;
  border-color: #0fb493 #0da284 #0c9075;

  -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;  

  font: 16px 'Droid Serif', serif;
  background: #0fb493;
  color: blue;
  cursor: pointer;

  text-shadow: 0 5px 0 rgba(255,255,255,0.4);
}

#submit:hover {       
    background-color: #0fb493;
    background-image: linear-gradient(#0a7d66, #0fb493);
}   

#submit:active {       
    background: #0fb493;
    outline: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;        
}

#submit::-moz-focus-inner {
       border: 0;  /* Small centering fix for Firefox */
}
.inputs {
    -webkit-border-radius: 20px 3px 3px 20px;
    -moz-border-radius: 20px 3px 3px 20px;
    -ms-border-radius: 20px 3px 3px 20px;
    -o-border-radius: 20px 3px 3px 20px;
    border-radius: 20px 3px 3px 20px;

    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    background: yellow;
    border: 5px solid #fba827;
    color: blue;
    font: 22px 'Droid Serif', serif;
    margin: 0 0 10px;
    padding: 15px 20px 15px 20px;
    width: 150px; 
}
</style>
<?php
error_reporting(0);
$values = $_POST['value'];

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

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


    if (ctype_alpha($values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
  $values="";
  $title=""; 
  
 }
    else  if ($values=="") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a integer value.');";
  echo "</script>";
  $title=""; 
  $values="";

  
 }
   }  


?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
   <div id="banner">
          <h1 align="center">Pascal Triangle Checker</h1>
      </div>
  <br>
<form action="" method="post">
 Enter a Number : <input id="text" type="text" class="inputs"  type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=5 required/>
   <input  id="submit"  type="submit"  name="check" value="Check Pascal Triangle" 
  title="Click here check for Pascal Triangle Values."/>
  <input id="submit"  type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>

<?php 
echo "<br>";
$rows=$values;
$coef=1;
$space=0;
$a=0;
$j=0;
    
    for($a=0;$a<$rows;$a++)
    {
        for($space=1;$space<=$rows-$a;$space++)
        echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
        for($j=0;$j<=$a;$j++)
        {
            if ($j==0||$a==0)
                $coef=1;
            else
               $coef=$coef*($a-$j+1)/$j;
echo "<font size='6' face='arial'>";   
            echo " &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
     .$coef."&nbsp;&nbsp";
echo "</font>";
        }
        echo "<br>";
    }
 
?>
  </body>
</html>



Monday, March 2, 2015

Armstrong Number Checker in PHP

In this short tutorial I would like to share with you sample program to check whether the given number by the user is an armstrong number of not. What our program will do is to ask the user to enter a number and then the user can select the find armstrong number by click the button. Our sample program will also check if the user has entered number or not by using PHP character validation functions. I hope you will find my work useful in your learning in PHP programming.

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

<html>
<title> Armstrong Number Checker</title>
<style>
body { 
  font-size:25px; 
  font-family:arial;
  color:blue;
  } 
  
#banner {
  width: 750px;
  background-color: yellow;
  height: 100px;
  margin: 0 auto;
  position: inherit;
  top: 100; 
  left: 0; 
  bottom:0; 
  right: 0;
  padding: 16px 16px;
  
  border-radius: 75px;
  border: 5px solid #fba827;
}
  /* BUTTONS */

#submit {
  background: #0a7d66;
  background-image: -moz-linear-gradient(#0fb493, #0a7d66);
  background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #6cbb6b),color-stop(1, #0fb493));
  
  margin: 0 0 0 2px;
  padding: 15px 20px;

  border-radius: 3px 70px 70px 3px;
  -moz-border-radius: 3px 70px 70px 3px;
  border-color: #0fb493 #0da284 #0c9075;

  -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
  box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;  

  font: 16px 'Droid Serif', serif;
  background: #0fb493;
  color: blue;
  cursor: pointer;

  text-shadow: 0 5px 0 rgba(255,255,255,0.4);
}

#submit:hover {       
    background-color: #0fb493;
    background-image: linear-gradient(#0a7d66, #0fb493);
}   

#submit:active {       
    background: #0fb493;
    outline: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;        
}

#submit::-moz-focus-inner {
       border: 0;  /* Small centering fix for Firefox */
}
.inputs {
    -webkit-border-radius: 20px 3px 3px 20px;
    -moz-border-radius: 20px 3px 3px 20px;
    -ms-border-radius: 20px 3px 3px 20px;
    -o-border-radius: 20px 3px 3px 20px;
    border-radius: 20px 3px 3px 20px;

    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
    background: yellow;
    border: 5px solid #fba827;
    color: blue;
    font: 22px 'Droid Serif', serif;
    margin: 0 0 10px;
    padding: 15px 20px 15px 20px;
    width: 150px; 
}
</style>
<?php
error_reporting(0);
$values = $_POST['value'];

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

}

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

$title = "======= The Result =======";
    if (ctype_alpha($values)) {
      echo "<script>";  
  echo "alert('PLEASE ENTER A NUMERIC VALUE.');";
  echo "</script>";
  $values="";
  $title=""; 
           $results="";
  $mess=" ";
 }
    else  if ($values=="") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a integer value.');";
  echo "</script>";
  $title=""; 
  $values="";
           $results="";
  $mess=" ";
 }
   }  


?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
   <div id="banner">
          <h1 align="center">Armstrong Number Checker</h1>
      </div>
  <br>
<form action="" method="post">
 Enter a Number : <input id="text" type="text" class="inputs"  type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=5 required/>
   <input  id="submit"  type="submit"  name="check" value="Check Armstrong Number" 
  title="Click here check if the given number is an armstrong."/>
  <input id="submit"  type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>

<?php 
 echo $title;
echo "<br>";

 $temp=$values;
  while($temp!=0)
     {
 $rem=$temp%10;
 $sum=$sum+$rem*$rem*$rem;
 $temp=$temp/10;
    }
 if($values==$sum)
  {
$mess = "is a Armstrong Number.";
$results = $values. " ".$mess;
}
else
{
$mess = "is Not an Armstrong Number.";
$results =  $values." ".$mess; 
}
 echo '<br>';
 echo $results;

 ?>
  </body>
</html>