Wednesday, March 11, 2015

Harmonic Sequence Solver in PHP

In this article I would like to share with you a simple program that I wrote in PHP I called this program Harmonic Sequence Solver in PHP. According to Wikipedia.org it is defined as follows In mathematics, the harmonic series is the divergent infinite series: Its name derives from the concept of overtones, or harmonics in music: the wavelengths of the overtones of a vibrating string are 1/2, 1/3, 1/4, etc., of the string's fundamental wavelength.

What our program will do is to ask the user to enter a number and then the user can press the find the harmonic sequence button and then our program will solve and generate the harmonic sequence values using PHP as our 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




Program Listing

<html>
<title> Harmonic Sequence Solver</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
$number= $_POST['value'];
error_reporting(0);

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



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



<?php 

 if(isset($_POST['check'])) {
echo "<br>";
     $number=0; 
$a=1;
     $result = 0.0;
        
$number= $_POST['value'];

        while($a <= $number)
        {
             echo "1/" .$a." + ";
             $result += + 1 / $a;

             $a++;
        }

      
$results = "Sum of Harmonic Series is " .$result;
   } 
   
   
   echo "<br><br>";
   echo $results;
 ?>
  </body>
</html>


Monday, March 9, 2015

Highest and Lowest Number Finder in Java

In this simple article I would like to share with you a sample program in Java that I wrote that will find the highest and lowest number given by our user. I'm using one dimensional array to accept and store integer numerical values and our program will check and compare which of the list of values given by the user in highest and lowest. Our program also ask the user if the they want to continue using the program or not by asking the user do you want to continue or not.

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

        public static void main(String[] args) {

                Scanner input = new Scanner(System.in);
                char a;
do
 {


 System.out.print("\n");
  System.out.println("==============================================");
  System.out.println("|| << HIGHEST AND LOWEST NUMBER FINDER  >>  ||");
    System.out.println("==============================================");
          System.out.print("\n");
  System.out.print("How Many Items To Be Process :=> ? ");

                int num = input.nextInt();

                int numbers[] = new int[num];
                  int largest_number = numbers[0];
 int smallest_number = numbers[0]+1;

                for(int i=0; i< numbers.length; i++)
                {

                   int b=i+1 ;

                   System.out.print("Enter Value in Item No. "+b + " : ");


                numbers[i] = input.nextInt();

                  if(numbers[i] > largest_number)
                             largest_number = numbers[i];
                     else if (numbers[i] < smallest_number)
                              smallest_number = numbers[i];

                }

                System.out.println("\n\n");
                System.out.println("THE LARGEST NUMBER IS   :=> " + largest_number);
                System.out.println("THE SMALLEST NUMBER IS  :=> " + smallest_number);
               System.out.println("\n\n");
               System.out.print("Do you Want To Continue (Y/N) :=> ");
            a=input.next().charAt(0);

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

}

}



Friday, March 6, 2015

Swap a Number in Java

In this short tutorial I will show you how to swap two numbers using Java as our programming language. What does our program do is very simple it will ask the user to enter two numbers and then our program will display the original arrangement of the two numbers and after that it will display the swap of arrangements of the two numbers. I've written a method of how to interchange the arrangement of the two numbers. I hope you will find my work useful and beneficial in your programming assignments and projects using 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;

class swap
{
    public static  int swap_values(int x,int y)
      {
     int temp=0;
     temp = x;
      x = y;
      y = temp;
      System.out.println("\n");
      System.out.println("====== SWAP VALUES ======");
 System.out.println();
 System.out.println(" 1ST VALUE :=>  " + x);
 System.out.println(" 2ND VALUE :=>  " + y);
      return 0;
       }

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

      int a, b;


      System.out.print("\n");
 System.out.println("==============================================");
 System.out.println("||    <<< SWAP OF TWO NUMBERS        >>>    ||");
 System.out.println("==============================================");
      System.out.print("\n");
      System.out.print("ENTER FIRST  VALUE :=> ");
      a = in.nextInt();
      System.out.print("ENTER SECOND VALUE :=> ");
      b = in.nextInt();
      System.out.println();
      System.out.println("====== ORIGINAL VALUES ======");
      System.out.println();
      System.out.println(" 1ST VALUE :=>  " + a);
      System.out.println(" 2ND VALUE :=>  " + b);
      swap_values(a,b);
      System.out.println("\n\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");
   }
}



Thursday, March 5, 2015

Age Solver in PHP

In this short article I would like to share with you a sample program that I wrote using PHP I called this program Age Solver. The purpose of this program will determine the age of the person by asking the person to enter the month, day and year which the person is being born. It will return the current age of the person once the user select the check age button. In addition I also add clear button which enables the user to erase the previous values and provide new birth date values in our 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



Sample Output of Our Program


Program Listing

<html>
<title> Age Solver</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);
$month = $_REQUEST['month'];
$day   = $_REQUEST['day'];
$year  = $_REQUEST['year'];

function age_solver($month,$day,$year) {
    list($cYear, $cMonth, $cDay) = explode("-", date("Y-m-d"));
    return ( ($cMonth >= $month && $day >= $day) || ($cMonth > $month) ) ? $cYear - $year : $cYear - $year - 1;
}

if(isset($_POST['submit'])) {
$result = "<center> Your age today is  " .age_solver($month,$day,$year)." years old.</center>";
}
if(isset($_POST['clear'])) {
 $result="";  $month="";  $day=""; $year=""; 
}
?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> Age Solver</h2>
  <br>
<form action="" method="post">
<center>
Month<input name="month" type="text" id="month" value="<?php echo $month ?>" size="2" maxlength="2" required autofocus>
Day<input name="day" type="text" id="day" value="<?php echo $day ?>" size="2" maxlength="2" required>
Year<input name="year" type="text" id="year" value="<?php echo $year ?>" size="2" maxlength="4" required>
<br><br>
  <input type="submit" name="submit" value="Check Age" title="Click here to know your age."> 
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
  </center>
</form><br>
<?php echo $result; ?>
</div>
</body>
</html>



Wednesday, March 4, 2015

Triangle Image in PHP

In this short article I will show you how to display an triangle image using PHP as our programming language. The code is just using two for loop statements to generate the image that we want.

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> Triangle Image </title>
<body bgcolor="lightgreen">
<h1> Triangle Image in PHP </h1>
<font face="arial" size="6">

<?php
error_reporting(0);
for($i=1;$i<=8;++$i)
 { 
 for($space=1;$space<=8-$i;++$space) 
 { 
 echo " &nbsp;  ";
 }
 while($k!=2*$i-1) 
 { 
 echo " <font color='red'>  * </font> ";
 ++$k;
 }
 $k=0; 
 echo "<br>";
 } 
 ?> </font>
 </body>
</html>


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