Thursday, March 12, 2015

Day Checker in PHP

   In this article I would like to share with you a sample program in PHP that I wrote that will determine or check what is the day in a given date by our user using PHP as programming language I called this program Date Checker. What our program will do is very simple it will ask the user to enter the month, day and year and then our program will determine what day will fall in the given date by our user. I also added a function that will ask the user if the user want to continue using the program or not. I hope you will find my work useful in your programming assignments and projects. 

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>
<head>
<title>Day Checker</title>
<head>
<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
$month = $_POST['mon'];
$day = $_POST['day'];
$year = $_POST['year'];
error_reporting(0);

 if(isset($_POST['clear'])) {
  $month="";
  $day=""; 
  $year="";
  }
?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
   <div id="banner">
          <h1 align="center">Day Checker</h1>
      </div>
  <br>
<form name="getDate" method="post" action="">
  <table border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td nowrap>
        <font size="5" face="Arial, Helvetica, sans-serif">
        Enter Date (mm/dd/yyyy): 
      </font>
      </td>
      <td nowrap>
        <font size="5" face="Arial, Helvetica, sans-serif">
        <input name="mon" type="text" size="12" maxlength="2"  value="<?php echo $month; ?>" autofocus required>
        /
        <input name="day" type="text" size="12" maxlength="2" value="<?php echo $day; ?>" required>
        /
        <input name="year" type="text" size="12" maxlength="4" value="<?php echo $year; ?>" required>       
        </font>
      </td>
      <td nowrap>
        <font size="5" face="Arial, Helvetica, sans-serif">
        Example "04/12/2001"
        </font>
      </td>
    </tr>
    <tr>
      <td>
        <font size="5" face="Arial, Helvetica, sans-serif">&nbsp;</font>
      </td>
      <td>
        <font size="5" face="Arial, Helvetica, sans-serif">
        <input type="submit" name="submit" value="Check Day" title="Click here to know the day in a given date">
        <input type="submit" name="clear" value="Clear" 
         title="Click here to clear text box and values on the screen"/>
</font>
      </td>
      <td>
        <font size="5" face="Arial, Helvetica, sans-serif">&nbsp;</font>
      </td>
    </tr>
  </table>
</form>
  
<?php  

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



$fontStyle = "size=\"5\" face=\"Arial, Helvetica, sans-serif\"";
$dayStrings = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

if (!isset($month) || !isset($day) || !isset($year))
  return;  


if (($month < 1) || ($month > 12) || 
    ($day < 1) || ($day > 31) ||
    ($year < 0))
  echo "<b>An invalid date ($month/$day/$year) was entered </b>";
  return;
}

  $t2 = array('0', '3', '2', '5', '0', '3', '5', '1', '4','6', '2', '4');
     
    $year-= $month < 3;
    $dow= ($year + $year/4 - $year/100 + $year/400 + $t2[$month-1] + $day) % 7;
echo "<font $fontStyle>";  
if ($dow > 6) { 
  echo "<br>"; 
  echo "Something is a miss, the day ($dow) is invalid";
} else {
  echo "<br>"; 
  echo "The day of the week for $month/$day/$year is:
  <b><font color='red'> $dayStrings[$dow]</font>.</b>";
}
echo "</font>";
}
?>
</body>
</html>


Day Checker in C++

In this article I would like to share with you a sample program in C++ that I wrote that will determine or check what is the day in a given date by our user using C++ as programming language. What our program will do is very simple it will ask the user to enter the month, day and year and then our program will determine what day will fall in the given date by our user. I also added a function that will ask the user if the user want to continue using the program or not. I hope you will find my work useful in your programming assignments and projects.

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 <ctype.h>

using namespace std;

char *check_day(int day){
   switch(day){
      case 0 :return("SUNDAY");
      case 1 :return("MONDAY");
      case 2 :return("TUESDAY");
      case 3 :return("WEDNESDAY");
      case 4 :return("THURSDAY");
      case 5 :return("FRIDAY");
      case 6 :return("SATURDAY");
      default:return("Sorry Invalid Value Please Try Again...");
   }
}

int check_day(int month,int day,int year){
    static int t2[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
    year-= month < 3;
    return (year + year/4 - year/100 + year/400 + t2[month-1] + day) % 7;
}

int main(){
    int month=0, day=0, year=0;
    char reply;
do {
    cout << "\n";
    cout << "\t=============================";
    cout << "\n";
    cout << "\t=======[ DAY CHECKER ]=======";
    cout << "\n";
    cout << "\t=============================";
    cout << "\n\n";
    cout << "\tPLEASE ENTER MONTH DAY AND YEAR :=> ";
    cin >> month >> day >> year;
    cout << "\n\n";
    cout << "\t Day in a given date is  " << check_day(check_day(month,day,year));
    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";
}


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>