Sunday, November 29, 2015

Payroll System in PHP

A simple payroll system that I wrote before in my programming class in PHP for my student programming laboratories activities. I hope you will find my work useful in learning PHP.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<head>
<title>Employees Payroll System</title>
</head>
<body bgcolor="yellow">
<style type="text/css">
fieldset {
position:relative;
margin-top:30px;
height:360px;
border-color: green;
padding-top:10px;
border-width : 2px;
}
legend {
    _position : absolute;
    _top : -10px;
    font-weight : bold;
    font-size : 120%;
    padding : 0px 10px 0px 10px;
    border-color: green;
    border-style : solid;
    border-width : 2px;
    background-color : #C3E0E8;
}
  div 
padding-buttom : 10px; 
width : 350px;
text-align: right;   
}
label 
{
padding-right: 10px;
}
 </style>
<?php
 error_reporting(0);
 
$emp_name = trim($_REQUEST['emp_name']);
$emp_position = trim($_REQUEST['emp_position']);
$emp_salary = trim($_REQUEST['emp_salary']);

$with_tax = trim($_REQUEST['with_tax']);
$sss = trim($_REQUEST['sss']);
$phil_health = trim($_REQUEST['phil_health']);
$pag_ibig = trim($_REQUEST['pag_ibig']);


// Clear the text field

if ($_REQUEST['submit2']){
   $emp_name = "";
   $emp_position ="";
   $emp_salary = "";
   $with_tax ="";
   $sss ="";
   $phil_health="";
   $pag_ibig="";
     
}
// Here To Perform Computation of the Payroll

if ($_REQUEST['submit']){
    
$add_deductions = ($with_tax + $sss + $phil_health + $pag_ibig);
$compute = ($emp_salary - $add_deductions);
$total_deductions = number_format($add_deductions,2,'.',',');
$net_pay = number_format($compute,2,'.',',');
}
?>
<hr color="red" >
<marquee bgcolor="#000080" style="color: #FFFFFF; 
font-family: comic sans ms" font size = 5 behavior="alternate" > 
Employees Payroll System
</marquee>
<hr color="red">
<font face="comic sans ms" size=2 color="blue">
<form method="post" action="">
<fieldset>
  <legend> Employees Payroll System </legend>
  <div>
<label>Employees Name</label>
<input type="text" name="emp_name" value="<?php echo $emp_name; ?>">
  <br>
  </div>
  <div>
<label>Employees Position</label>
<input type="text" name="emp_position" value="<?php echo $emp_position; ?>">
   <br>
   </div>
   <div>
<label>Employees Salary</label>
<input type="text" name="emp_salary" value="<?php echo $emp_salary; ?>">
  <br>  <br>
  </div>
     <label>TOTAL DEDUCTIONS</label> <br>
     <div>
<label>With Holding Tax</label>
<input type="text" name="with_tax" value="<?php echo $with_tax; ?>">
</div>
   
  <div>
<label>Social Security System </label>
<input type="text" name="sss" value="<?php echo $sss; ?>">
  
  </div>
   <div>
  <label>PAG-IBIG Funds</label>
<input type="text" name="pag_ibig" value="<?php echo $pag_ibig; ?>"><br />
  </div>
 <div>
  <label>PHILHEALTH Insurance</label>
<input type="text" name="phil_health" value="<?php echo $phil_health; ?>"><br />
</div>
<br>
    <input type="submit" name="submit" value="Compute Salary"
    title="Click here to compute the salary.">
<input type="submit" name="submit2" value="Clear"
title="Click here to clear the textbox." >
  <br> <br>
   <font face="comic sans ms" size=3 color="blue">
   <div>
   <label> Employees Total Deductions $ </label>
<?php echo $total_deductions; ?><br />
  </div>
  <div>
   <label> Employees Net Pay $ </label>
<?php echo $net_pay; ?><br />
  </div>
  </font>
  </fieldset>
</form>
</font>
</body>
</html>

High and Low Number Checker in PHP

This sample program that I wrote in PHP will check for the highest and lowest number from the five number given by the user using one dimensional array in PHP. Take note I did not use any built in function in PHP like Max and Min function to determine the highest and lowest number. I hope you will find my work useful in learning how to program in PHP.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

<?php
error_reporting(0);
    
    
    $a = $_POST["numbers"][0];
    $b = $_POST["numbers"][1];
    $c = $_POST["numbers"][2];
    $d = $_POST["numbers"][3];
    $e = $_POST["numbers"][4];

if  ($_POST['send']) 
  {

      $list=array($a,$b,$c,$d,$e);

    $highest_number=0;
    
    $lowest_number=0;

    $high=0;
    
    $low=0;
    
    // checking for highest number
    
 $highest_number = $list[0];
    
    foreach($list as $high)
    {
      if ($highest_number < $high)
      {
        $highest_number = $high;
      } 
    }
                 
// checking for lowest number

$lowest_number = $list[0];

  foreach($list as $low)
      {
        if ($lowest_number > $low)
        {
          $lowest_number = $low;
        } 
     }
 }   


 if ($_POST['clear'])
   {
   $a=""; $b=""; $c=""; $d=""; $e="";
   $highest_number="";
   $lowest_number="";  
  }

?>
<html>
 <style>
 body {
  font-family:arial;
  font-size:12;
  }
</style>   
<title> Highest and Lowest Number Checker</title>
<form action = "" method = "POST">
<body>
<h3> Highest and Lowest Number Checker </h3>
<table border = "0">
<tr>
   <td> 1st Value </td>
   <td> <input type = "text" name ="numbers[]" value = "<?php echo $a;?>" size="5" autofocus required>
   </tr>
   <tr>
   <td> 2nd Value </td>
   <td> <input type = "text" name ="numbers[]"  value = "<?php echo $b;?>" size="5"  required>
   </tr>
   <tr>
   <td> 3rd Value </td>
   <td> <input type = "text" name ="numbers[]"  value = "<?php echo $c;?>" size="5" required>
   </tr>
   <tr>
   <td> 4th Value </td>
   <td> <input type = "text" name ="numbers[]"  value = "<?php echo $d;?>" size="5" required >
   </tr>
   <tr>
   <td> 5th Value </td>
   <td> <input type = "text" name ="numbers[]"  value = "<?php echo $e;?>" size="5" required>
   </tr>
   <tr>
   <td> &nbsp;</td>
   </tr>
   <tr>
   <tr>
   <td> <b> Highest Number </b> </td>
   <td> <input type = "text"  value = "<?php echo $highest_number;?>" size="5" readonly>
   </tr>
   <tr>
   <td> &nbsp;</td>
   </tr>
   <tr>
   <td> <b>Lowest Number </b> </td>
   <td> <input type = "text"  value = "<?php echo $lowest_number;?>" size="5" readonly>
   </tr>
   <tr>
   <td> &nbsp;</td>
   </tr>
   <tr>
   <td colspan = 3>
        <input type = "submit" name="send" value = "OK" title="Click here to check highest and lowest number.">
        &nbsp;&nbsp;
        <input type = "submit" name="clear" value = "Clear" title="Click here to clear text boxes.">
   </td>
   </tr>
   </table>
   </form>
  </body>
 </html>


Ordinal Values in PHP

This sample program that I wrote in PHP as programming language to create the ordinal values. The code is very simple and easy to understand. I intended my work for beginners in PHP programming.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<?php
echo "<br>";
echo "<font face='arial'>";
echo "<h2 align='center'> Ordinal Values in PHP </h2> </font>";
echo "<br>";
for ($a=1; $a<=100; $a++) {

 $mod100 = $a % 100;
 $mod10 = $a % 10;

if ($mod10 == 1 && $mod100 != 11) {

   $message= "st";

} else if  ($mod10 == 2 && $mod100 != 12) {
 $message="nd";
}
else if  ($mod10 == 3 && $mod100 != 13) {
$message= "rd";
} else {
 $message= "th";
 }


 echo "<font face='arial' size='5'>";
 echo " ".$a.$message."</font>";
}

?>

Thursday, November 26, 2015

Simple Interest Solver in PHP

A simple program that I wrote in PHP to compute the interest rate of a loan of a customer or client. The code is very simple and easy to understand good for beginners in PHP programming.

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

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

<?php

  error_reporting(0);

$principle = $_POST['principle'];
$rate = $_POST['rate'];
$time = $_POST['time'];


 if ($_POST['clear'])
   {
   $principle = "";
   $rate = "";
   $time = "";
   $display_results = "";
}


  if  ($_POST['compute']) 
  {
   $interest =($principle*$rate*$time)/100;
   $display_results = round($interest,2);
 }

?>
<html>
 <style>
 body {
  font-family:arial;
  font-size:12;
  }
</style>   
<title> Simple Interest Solver in PHP</title>
<form action = "" method = "POST">
<body>
<h2> Simple Interest Solver in PHP </h2>
<br>
<table border = 3>
<tr>
   <td> Principle Amount : </td>
   <td> <input type = text name = "principle" value = "<?php echo $principle;?>"  size="10" autofocus>
   </tr>
   <tr>
   <td> Rate of Interest : </td>
   <td> <input type = text name = "rate" value = "<?php echo $rate;?>"  size="5">
   </tr>
   <tr>
   <td> Time Period : </td>
   <td> <input type = text name = "time" value = "<?php echo $time;?>" size="10"  >
   </tr>
   <tr>
     <td> &nbsp; </td>
    </tr>
   <tr>
   <td>Interest Rate Php </td>
   <td> <input type = text name = "solve_interest" value = "<?php echo $display_results;?>" size="12" readonly >
   </tr>
   <tr>
     <td> &nbsp; </td>
    </tr>
   <td colspan = 3>
        <input type = "submit" name="compute" value = "Compute Interest" title="Click here to compute for interest rate.">
        <input type = "submit" name="clear" value = "Clear" title="Click here to clear text boxes.">
   </td>
   </tr>
   </table>
   </form>
     </body>
   </html>








Display the result in the same page in PHP

In this sample program I would like to share with you how to create a program that will accept input values from the user and then display the values in PHP using the same page. The code is very simple and easy to understand ideal for beginners in PHP programming.

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

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing


<?php
error_reporting(0);
$fname = $_POST['fn'];
$age = $_POST['a'];
$course = $_POST['crs'];
 
 
 if ($_POST['clear'])
   {
    
  $fname="";
  $age="";
  $course="";
  $message1="";
  $message2="";
}


  if  ($_POST['send']) 
  {
    $message1 = "Hello " .$fname;
    $message2 = "Your are $age years old and your course is $course.";
    
}


?>
<html>
 <style>
 body {
  font-family:arial;
  font-size:12;
  }
</style>   
<title> BUILT IN FUNCTIONS</title>
<form action = "" method = "POST">
<body>
<table border = 3>
<tr>
   <td> Name: </td>
   <td> <input type = text name = fn value = "<?php echo $fname;?>"  size="50" autofocus>
   </tr>
   <tr>
   <td> Age: </td>
   <td> <input type = text name = a value = "<?php echo $age;?>"  size="3">
   </tr>
   <tr>
   <td> Course: </td>
   <td> <input type = text name = crs value = "<?php echo $course;?>" size="50"  >
   </tr>
   <tr>
   <td colspan = 3>
        <input type = "submit" name="send" value = "Ok" title="Click here to display values.">
        <input type = "submit" name="clear" value = "Clear" title="Click here to clear text boxes.">
   </td>
   </tr>
   </table>
   </form>
  <?php
     echo "<br><br>";
    echo "<font face='arial' size='4'>";
    echo  $message1;
    echo "<br>";
    echo $message2;
    echo "</font>";
  ?>  
   </body>
   </html>

 

Wednesday, November 25, 2015

Square a value in C++

A simple program that I wrote in C++ that will square a number based on the number given by the user.

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

My mobile number here in the Philippines is 09173084360.


Program Listing


#include <iostream>
#include <iomanip>

 using namespace std;

// Global Variable

int values[6],a=0;

 void accept_data(void);
 void display_result(void);

 void accept_data()
 {
    for (a=1; a<=5; a+=1) {
          cout << "Enter Value No. "
               << a << " : ";
           cin >> a[values];
      }
 }

 void display_result()
 {
            cout << "\n\n";
            cout << setw(5)
                 << "VALUES"
                 << setw(18)
                 << "SQUARE VALUES";
            cout << "\n\n";
            for (a=1; a<=5; a+=1) {

           cout <<"\n" << setw(3) << a[values]
                << setw(16)
                << a[values] * a[values];
           }
        cout << "\n\n";
        system("pause");
 }
main() {

     cout << "\n\n";
     cout << "\t\t Square A Value Version 1.0";
     cout << "\n\n\n";

    accept_data();
    display_result();
 }


Simple Interest Solver In Pascal

A simple loan interest solver that I wrote using Pascal as my programming language that will solve for the interest rate of the loan of a person. I am using Turbo Pascal 5.5 For DOS as my Pascal compiler.

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

My mobile number here in the Philippines is 09173084360.



Sample Program Listing


Program Listing


Program Simple_Interest_Solver;
Uses Crt;

Var p,r,t,solve_interest : Real;

Begin
  p:=0.00;
  r:=0.00;
  t:=0;
  solve_interest := 0.00;

  clrscr;

  write('Simple Interest Solver');
  writeln; writeln;
  write('Enter the Principle Amount : Php ');
  readln(p);
  write('Enter the Rate of Interest :     ');
  readln(r);
  write('Enter the Time Period      :     ');
  readln(t);

  solve_interest:=(p*r*t)/100;

  writeln; writeln;
  write('The simple interest is Php ',solve_interest:5:2,'.');
  writeln; writeln;
  write('End of Program');
  readln;
End.

Simple Math Calculator in Pascal

A simple math calculator that I wrote in Pascal programming language that will ask the user to give two numbers and then the user will select the operand either plus, subtract, multiplication and division mathematical operations. I am using Turbo Pascal 5.5 For DOS as my pascal compiler in this sample program.

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

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing


Program Basic_Calculator;
Uses Crt;

Var

 Operator   : Char;
 Opt1,Opt2  : Integer;
 Sum,Subtract, Multiply: Integer;
 Divide     : Integer;
 Result     : Integer;

Begin

  clrscr;
  Opt1 := 0; Opt2 := 0;

  write('Simple Math Calculator');
  writeln; writeln;
  write('Enter Two Numbers : ');
  readln(Opt1,Opt2);
  write('Select Operators +,-,* and / : ');
  readln(Operator);
  if (Operator = '+') then
    Begin
      Sum := (Opt1 + Opt2);
      Result := Sum;
    End


   else if (Operator = '-') then
    Begin
      Subtract := (Opt1 - Opt2);
      Result := Subtract;

    End

   else if (Operator = '*') then
    Begin
      Multiply := (Opt1 * Opt2);
      Result := Multiply;

    End

   else if (Operator = '/') then
    Begin
      Divide := (Opt1 DIV Opt2);
      Result := Divide;

    End;


  writeln;
  writeln;
  Write('The result is ' ,Result,'.');
  readln;

End.







Consonants and Vowels Counter in C

A sample program that will ask the user to enter a work or a sentence and then the program will count how many consonants and vowels in a given word or sentence by the user. Take note I am using Turbo C 2.0 For DOS as my C compiler in this program.

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

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing

/* Consonants and Vowels Counter               */
/* Written By: Mr. Jake R. Pomperada, MAED-IT  */
/* Date  : November 25, 2015                   */
/* Tools : Turbo C 2.0  For DOS                */

#include <stdio.h>
#include <ctype.h>
#include <conio.h>

  main()
    {
char strings[200];
int vowels=0,consonants=0,i=0;
clrscr();
printf("Enter a word or sentence : ");
gets(strings);

while(strings[i] != '\0')
{
if (toupper(strings[i])=='A' || toupper(strings[i])=='E' ||
toupper(strings[i])=='I' ||  toupper(strings[i])=='O'||
toupper(strings[i])=='U')

vowels++;



  if (toupper(strings[i])=='B' || toupper(strings[i])=='C' ||
toupper(strings[i])=='D' || toupper(strings[i])=='F'||
toupper(strings[i])=='G' || toupper(strings[i])=='H' ||
toupper(strings[i])=='J' || toupper(strings[i])=='K'||
toupper(strings[i])=='L' || toupper(strings[i])=='M' ||
toupper(strings[i])=='N' || toupper(strings[i])=='P'||
toupper(strings[i])=='Q' || toupper(strings[i])=='R' ||
toupper(strings[i])=='S' || toupper(strings[i])=='T'||
toupper(strings[i])=='V' || toupper(strings[i])=='W' ||
toupper(strings[i])=='X' || toupper(strings[i])=='Y' || 
                toupper(strings[i])=='Z')

consonants++;

i++;
}
printf("\n\n");
printf("===== DISPLAY RESULTS =====");
printf("\n\n");
printf("Total Number of Vowels     : %d. ", vowels);
printf("\n\n");
printf("Total Number of Consonants : %d.   ",consonants);
getch();
}