Monday, September 26, 2016

Calculator in PHP using Drop Down Menu

A simple calculator program that I wrote in PHP using Drop Down Menu to select the mathematical operator such as addition, subtraction, multiplication and division using combo box in HTML.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing

<html>
<head>
<?php
error_reporting(0);

 $a =  $_REQUEST['num1'];
 $b =  $_REQUEST['num2'];
?>

<title>Simple Calculator</title>
</head>
<style type="text/css">
 body
 {
 background-color:yellow;
 font-family:arial;
 font-size:14px;
 font-weight:bold;
 }

 #result
 {
 color:green;
 font-family:arial;
 font-size:16px;
 }



 input[type="text"] {
 height: 50px;
 width: 50px;
 font-family:arial;
 font-size:25px;
 font-weight:bold;
}

#opt{
 width:250px;   
}
</style>
<script language="javascript">
 function validate_form()
 {
 var num1 = document.entryform.num1;
 var num2 = document.entryform.num2;
 if (num1.value=="" || num1.value==null)
 {
 alert("Please specify value on first box");
 num1.focus();
 return false;
 }
 else if (num2.value=="" || num2.value==null)
 {
 alert("Please specify value on second box");
 num2.focus();
 return false;
 }
 }
</script>
<body>
<?php
if (isset($_REQUEST['clear']))
 {
  $a="";
  $b="";  
 }
 ?>
<form method="post" onSubmit="return validate_form(this)" name="entryform">
<fieldset>
 <legend>Simple Calculator</legend>
 <input type="text" name="num1" value="<?php echo $b; ?>"  autofocus>
 <select name="opt_math">
 <option value="+">+
 <option value="-">-
 <option value="*">*
 <option value="/">/
 </select>
 <input type="text" name="num2" value="<?php echo $a; ?>"><br><br>
 <input type="submit" name="submit" value="Compute"> &nbsp; &nbsp;
<input type="submit" name="clear" value="Clear">
 <br><br>

 <span id="result">
 Result is
 <strong>
 <?php
if ($_REQUEST['opt_math']=="+"){
 echo  $a+$b;
 }
 else if ($_REQUEST['opt_math']=="-"){
 echo $a-$b;
 }
 else if ($_REQUEST['opt_math']=="/"){
 echo $a/$b;
 }
 else if ($_REQUEST['opt_math']=="*"){
 echo $a*$b;
 }

 ?>
 </strong>
 </span><br><br><br>
  </fieldset>
 </form>
 </body>
 </html>



Count Capital and Small Letters in PHP

Here is a very short script that I wrote in PHP that will count the number of Capital and Small letter in a given string. The code is very simple to use and understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.



Program Listing


<?php

function CountCaps($string) {
  return strlen(preg_replace('/[^A-Z]+/', '', $string));
}

function CountSmall($string) {
  return strlen(preg_replace('/[^a-z]+/', '', $string));
}


$str = 'WeLcoMe HOme';

$result1 = CountCaps($str);

$result2 = CountSmall($str);

echo 'The word is ' .$str;
echo '<br><br>';
echo 'Number of Capital Letters ' .$result1.'.';
echo '<br><br>';
echo 'Number of Capital Letters ' .$result2.'.';

?>

Area of Rectangle in C#

Here is a another simple program that I wrote in C# to ask the user to give the length and breath of the rectangle and the our program will compute for its area. I am using Visual Studio 2010 Ultimate Edition in this program.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int length= 0, breadth=0,solve_area=0;

            if (!int.TryParse(textBox1.Text, out length))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }
            else  if (!int.TryParse(textBox2.Text, out breadth))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox2.Text = "";
                textBox1.Focus();
            }


            else
            {
                length = Convert.ToInt32(textBox1.Text);
                breadth = Convert.ToInt32(textBox2.Text);

                solve_area = (length * breadth);
                label5.Text = "The Area of the Rectangle is " + solve_area + ".";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            label5.Text = " ";
            textBox1.Focus();
        }
    }
}







Area of Square Solver in C#

Here is a simple program that I wrote using C# as my programming language that will ask the user to give the side length of the square and then our program will compute the area of the square. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int side = 0, area=0;

            if (!int.TryParse(textBox1.Text, out side))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox1.Focus();
            }

            else
            {
                side = Convert.ToInt32(textBox1.Text);

                area = (side * side);
                label3.Text = "The Area of the Square is " + area + ".";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            label3.Text = "";
            textBox1.Focus();
        }
    }
}







Removing Placeholder in JQuery

A very simple program that I wrote using JQuery that will remove the placeholder in the input textbox in HTML. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My mobile number here in the Philippines is 09173084360.


Program Listing

<!DOCTYPE html>
<html lang="en">
    <head>
      <meta charset="utf-8">
      <title>Remove Place Holder</title>
      <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    </head>
<style>
body {
 font-family:arial;
 font-size:16px;
 font-weight:bold;
}
  label{
    display: table-cell; 
    text-align: right;
    }
input {
  display: table-cell;
  margin-bottom: 10px; /* distance between input box */
  font-family:arial;
  font-size:16px;
  color: blue;
}

div.row{
    display:table-row;
}
</style>
    <body>

<div>
<h3> Remove Place Holder in JQuery </h3>
<br>
  <div class="row"><label>Person's Name </label>&nbsp;&nbsp;&nbsp;&nbsp;<input id="txtName" placeholder="Person's Name" type="text"></div>
      <div class="row"><label>Home Address </label>&nbsp;&nbsp;&nbsp;&nbsp;<input id="txtAddress" placeholder="Home Address" type="text"></div>
      <div class="row"><label>Zip Code </label>&nbsp;&nbsp;&nbsp;&nbsp;<input id="txtZip" placeholder="Zip Code" type="text"></div> 
 <div class="row"><label>Telephone Number </label>&nbsp;&nbsp;&nbsp;&nbsp;<input id="txtTelephone" placeholder="Telephone Number" type="text" size="20"></div> 
       </div>
   <script type="text/javascript">

// Person's Place Holder 
$('#txtName').focus(function(){
  $(this).attr('placeholder','');
});
$('#txtName').focusout(function(){
  $(this).attr('placeholder','Enter Persons Name');
});
   
   
// Home Address Place Holder 
$('#txtAddress').focus(function(){
  $(this).attr('placeholder','');
});
$('#txtAddress').focusout(function(){
  $(this).attr('placeholder','Enter Home Address');
});

// Zip Code Place Holder
$('#txtZip').focus(function(){
  $(this).attr('placeholder','');
});
$('#txtZip').focusout(function(){
  $(this).attr('placeholder','Enter Zip Code');
});

// Telephone Place Holder
$('#txtTelephone').focus(function(){
  $(this).attr('placeholder','');
});
$('#txtTelephone').focusout(function(){
  $(this).attr('placeholder','Enter Telephone Number');
});
    </script>

    </body>
</html>

Friday, September 23, 2016

Decimal To Roman Numeral Converter in Visual Basic

A simple program that I wrote using Visual Basic 5 to accept decimal number from the user and then our program will convert the given number into it's roman numeral equivalent. The code is very short and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.






Sample Program Output


Program Listing


Function Convert_To_Roman(value) As String
    Dim arabic As Variant
    Dim roman As Variant
 
    arabic = Array(1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
    roman = Array("M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I")
 
    Dim i As Integer, result As String
 
    For i = 0 To 12
        Do While value >= arabic(i)
            result = result + roman(i)
            value = value - arabic(i)
        Loop
    Next i
 
    Convert_To_Roman = result
End Function

Private Sub Command1_Click()
Label3.Caption = "The Roman Numeral Equivalent of " & Val(Text1.Text) _
& " is " & Convert_To_Roman(Val(Text1.Text)) & "."

End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label3.Caption = ""
Text1.SetFocus
End Sub





Monday, September 19, 2016

Largest and Smallest Number in Perl

A very simple and short program that I wrote in PERL that will ask the user to give five numbers and then our program will find out which of the given number is the largest and the smallest.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

use strict;
use warnings;

use strict;

my @foo;


print "Largest and Smallest Number in PERL";
print "\n\n";
while (@foo < 5) {
   chomp(@foo=<>);
    push @foo, $num;
}
@foo = sort{$num <=> $b} @foo;

my $smallest = shift (@foo);
my $largest  = pop (@foo);

print "The Smallest Number is $smallest\n";
print "The Largest Number is $largest\n";


Factorial Program Using Functions in PERL

A simple factorial program that uses Functions in Perl that will ask the user to give a number and then our program will compute the factorial value based on the given number by our user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

sub factorial {
  my($num) = @_;
  if ($num == 1) {
    return 1;   
  } else {
    return $num*factorial($num - 1);  
  }
}

print "Factorial Program in Perl";
print "\n";
print "Enter a Number : ";
$number = <>;
chop ($number); 
print "\n";
print factorial($number);

Word Count in Perl

Here is a very simple program that I wrote using PERL as my programming language that will ask the user to give a sentence and then our program will count the number of words in the given sentence by the user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

$wordcount = 0; 
print "\n";
print "Word Count in PERL";
print "\n\n";
print "Enter a sentence : ";
$sentence = <>;
chop ($sentence); 
@array = split(/ /,$sentence); 
$wordcount += @array; 

print "\n";   
print "Total number of words in the sentence is $wordcount."; 
print "\n\n";   
print "End of Program";
print "\n";   


User Information System With Upload Picture in PHP and MySQL using BootStrap

This is an update version of our code with my best friend Dave Marcellana that will manage the information of the user using PHP and MySQL. We are using BootStrap framework for our web design layouts. The best thing about this code I was able to fix the bugs of upload the picture in the database it is already been fix and tested very well. This code is also allows the user to upload not only their contact information in details but also their picture. I hope you will find our work useful.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.




Table Structure








Sample Program Output