Tuesday, February 17, 2015

Simple Interest Solver in PHP

In this article I will show you how to compute simple amount interest rate solver using PHP. This program is very useful if you want to learn how much the interest should be paid in a loan in a certain amount of time. The code is very short and very easy to understand I hope you will find my work useful.

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> Simple Interest Solver</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
 label{
    display: table-cell;
    text-align: justify;
}
input {
  display: table-cell;
}
div.row{
    display:table-row;
}
</style>
<?php
error_reporting(0);

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

$amount2 = (float)$amount;
$rate2   = (float)$rate;


$Solve_Interest = ($amount2 * $rate2 * $time) / 100;
  
$Total_Amount = ($amount2 + $Solve_Interest);

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

$title .= " ===== GENERATED RESULT ===== " ."<BR><BR>";
$title .= "The computed interest is Php ".number_format($Solve_Interest,2,'.','').".<br><br>"; 
$title .= "The Total Amount to be paid is Php ".number_format($Total_Amount,2,'.','')."."; 
    
       
}
if(isset($_POST['clear'])) {
  $amount = " ";
  $rate = " ";
  $time = " ";
  $title= " ";
   
}
?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> Simple Interest Solver</h2>
 <form action="" method="post"><div>
  <div class="row"><label> Enter Principal Amount : </label> <input type="text" name="amount" 
           value="<?php echo $amount; ?>" autofocus required size=10/><br> </div>
<div class="row"> <label> Enter Rate of Interest  : </label><input type="text" name="rate" 
           value="<?php echo $rate; ?>" required size=10/><br> </div>
<div class="row"> <label> Enter Period of Time    : </label> <input type="text" name="time" 
           value="<?php echo $time; ?>"  required size=10/> </div> </div>   
  <br>
   <input type="submit" name="check" value="Compute Interest" 
  title="Click here to compute the Interest Amount."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>

<br> <br>

<?php 
echo $title;
 ?>
  </body>
</html>


Reverse a Number in PHP

In this article I have a wrote another simple program that uses PHP as my programming language I called this program reverse a number. What this program will do is very simple it will ask the user to enter a series of number digits and then our program will reverse the arrangement of the number let say the user give 12345 our program will convert in 54321. I hope you will find my program useful in learning how to write a program 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



Sample Output of Our Program



Program Listing


<html>
<title> Reverse a Number</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);

$values = $_POST['value'];

  

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 { 
  $rem =0; $rev =0; 
    $originalnum = $values; 
  
  while($values > 1) { 
      $rem = $values %10; 
      $rev = ($rev * 10)+ $rem; 
      $values = $values/10; 
 } 
 
$title .= " ===== GENERATED RESULT ===== " ."<BR><BR>";
$title .= "Original Number Arrangement  : ". $originalnum."<br><br>"; 
$title .= "Reverse Number  Arrangement  : ". $rev; 

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

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> Reverse a Number</h2>
  <br>
<form action="" method="post">
 Enter a Number : <input type="text" name="value" 
           value="<?php echo $originalnum; ?>" autofocus  size=20/>
   <input type="submit" name="check" value="Reverse Number" 
  title="Click here to reverse the number."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>

<br> <br>

<?php 
echo $title;
 ?>
  </body>
</html>





Monday, February 16, 2015

Area of the Circle Calculator

In this article I would like to share with you how to compute the area of the circle and its circumference using PHP as our programming language. What the program will do is to ask the user to enter the radius of the circle and then compute the corresponding area and circumference of the circle in meters. 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> Area of a Circle Calculator</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);

$values = $_POST['value'];

    $radius = (float)$values; 
    $circle = $radius * 2 * pi();
    $area = pow($radius, 2) * pi();
 


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 radius of the circle is " .$values.".<br><br>";
 $title .= "The circumference of the circle is: " 
            .number_format($circle,2,'.','')." m <br>";
      $title .= "The area of the circle is: ".number_format($area,2,'.','')." m&sup2;<br>";
 
       }  
   }  

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

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center"> Area of a Circle Calculator</h2>
  <br>
<form action="" method="post">
 Enter a Radius of the Circle : <input type="text" name="value" 
           value="<?php echo $values; ?>" autofocus  size=20/>
   <input type="submit" name="check" value="Compute Area" 
  title="Click here to know the area of the circle."/>
  <input type="submit" name="clear" value="Clear" 
  title="Click here to clear text box and values on the screen"/>
</form>

<br> <br>

<?php 
echo $title;
 ?>
  </body>
</html>


Friday, February 13, 2015

Capital Letters Counter in PHP

In this article I would like to share with you a sample program that enables the user to count the number of capital letters in a given word or sentence by our user. I wrote a function called count_capital_letters to count the occurrence of capital letters in a given word or sentence. I hope you will find my work useful in your programming assignments or projects 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




Sample Output of Our Program

Program Listing

<html>
<title> Capital Letters Counter</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>
<?php
error_reporting(0);

$values = $_POST['value'];

// function to count the number of capital letters
// in a given word or sentence.

function count_capital_letters($string) {
   return strlen(preg_replace("/[^A-Z]/","", $string));
}
  
if(isset($_POST['check'])) {

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a number.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }

 if ($values != " ") {

   $results .=  "==== REPORT ==== ";
   $results .=  "<br><br>";
   $results .= "The sentence or the word is "
            ."<font color='RED'>".$values."</font>"."."
."<br><br>";
   $results .= "The number of capital letters is "
                ."<font color='RED'>".count_capital_letters($values)."</font> ".
" in a given word or sentence.";
   }
 }
      

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

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Capital Letters Counter in PHP</h2>
  <br>
<form action="" method="post">
 Enter a Word or a Sentence : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=40/>
 <br><br>
   <input type="submit" name="check" value="Count Capital Letters" 
  title="Click here to count the number of capital letters in a given word or 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>


Thursday, February 12, 2015

Romal Numeral To Decimal Converter in PHP

I would like to share with you a simple program that I wrote PHP as my programming language I called this program Roman Numeral To Decimal Converter in PHP. What this program will do is to ask the user to enter roman numeral value format and then the user can select convert to decimal button to convert the roman numeral value to its decimal value equivalent. The code is very short and simple I also added a function if the user give invalid value such as words, letters or even special character our program will not hang or malfunction in such situation encounter.

 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>Roman Numeral To Decimal Converter</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>


<?php
error_reporting(0);

$values = $_POST['value'];

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

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a number.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }

 if ($values != " ") {
 
  $natural_roman = array(1000 => 'M', 500 => 'D', 100 => 'C', 50 => 'L', 10 => 'X', 5 => 'V', 1 => 'I');

    function convert_to_decimal($numeral)

    {

        global $natural_roman;

        $numeral = str_replace(

                                array('CM', 'CD', 'XC', 'XL', 'IX', 'IV'),

                                array('DCCCC', 'CCCC', 'LXXXX', 'XXXX', 'VIIII', 'IIII'),

                                trim($numeral)

                            );                        

        for ($total = 0, $n = 0; $n < strlen($numeral); $n++)

        {

            if ($numeral[$n] == 'I' && $n <> strlen($numeral)-1 && $numeral[$n+1] <> 'I')

                $number = array_search($numeral[++$n], $natural_roman)-1;

            else

                $number = array_search($numeral[$n], $natural_roman);

            $total += $number;

        }

        return $total;

    }

    

    
   $results .=  "==== REPORT ==== ";
   $results .=  "<br><br>";
   $results .= "The roman numeral " .$values." it's Decimal Equivalent is "
               .convert_to_decimal($values).".";
   
  
   }
   
    }
       
    

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

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Roman Numeral To Decimal Converter</h2>
  <br>
<form action="" method="post">
 Enter Roman Numeral : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=10/>
 <br><br>
   <input type="submit" name="check" value="Convert To Decimal" 
  title="Click here to convert roman numeral to decimal equivalent."/>
  <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>


Decimal To Romal Numeral Converter in PHP

I would like to share with you a simple program that I wrote PHP as my programming language I called this program Decimal To Roman Numeral Converter in PHP. What this program will do is to ask the user to enter any number in integer format and then the user can select convert to roman numeral button to convert the decimal value to its roman numeral equivalent. The code is very short and simple I also added a function if the user give invalid value such as words, letters or even special character our program will not hang or mal function in such situation encounter.

 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> Decimal To Roman Numeral Converter</title>
<style>
body { 
  font-size:20px; 
  font-family:arial;
  color:blue;
  } 
</style>


<?php
error_reporting(0);

$values = intval($_POST['value']);

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

  if ($values==" ") {
      echo "<script>";  
  echo "alert('It Cannot Be Empty!!! Please enter a number.');";
  echo "</script>";
  $values=" ";
  $results=" ";
     }

 if ($values != " ") {

  $natural_roman = array(1000 => 'M', 500 => 'D', 100 => 'C', 50 => 'L', 10 => 'X', 5 => 'V', 1 => 'I');

    function convert_to_roman($natural)

    {

        global $natural_roman;

        reset($natural_roman);

        while (list($key, $value) = each($natural_roman))

        {

            while ($natural >= $key)

            {

                $natural -= $key;

                $rn .= $value;

            }

        }

        return str_replace(

                                array('DCCCC', 'CCCC', 'LXXXX', 'XXXX', 'VIIII', 'IIII'),        

                                array('CM', 'CD', 'XC', 'XL', 'IX', 'IV'),

                                $rn

                            );        

    }

    
   $results .=  "==== REPORT ==== ";
   $results .=  "<br><br>";
   $results .= "The number " .$values." it's Roman Numeral equivalent is "
               .convert_to_roman($values).".";
   
  
   }
   
    }
       
    

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

?>
<body style='background-color:lightgreen'>
<div style='width:800px;margin:auto'>
  <br> <h1 align="center">Decimal To Roman Numeral Converter</h2>
  <br>
<form action="" method="post">
 Enter a Sentence : <input type="text" name="value"    value="<?php echo $values; ?>" autofocus  size=10/>
 <br><br>
   <input type="submit" name="check" value="Convert To Roman Numeral" 
  title="Click here to convert decimal to roman numeral equivalent."/>
  <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>