Tuesday, September 30, 2014

Centimeter To Feet Converter in JavaScript

This program that I wrote in JavaScript will convert the height of the person from centimeter to feet. I'm using HTML as my markup language and JavaScript to perform as series of computation and conversion of values from centimeter to feet. I hope you will find my work useful in your programming projects and assignments using JavaScript.

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

Thank you very much.


Sample Output of Our Program

Program Listing

<HTML>
<TITLE> Height Converter </TITLE>
<BODY BGCOLOR="lightgreen">
<font face="comic sans ms" size=5>
<TABLE cellSpacing=0 cellPadding=0 width=250 border=0>
<H3>  Height Converter </center> </H3>
<FORM name=cminch>
        <TBODY>
        <TR>
          <TD>
            <FONT face="comic sans ms"><INPUT 
            onblur=cmconvert() value=2.54 name=cm> CM</FONT></TD>
        </TR>
        <TR>
          <TD>
            <FONT face="comic sans ms"><INPUT 
            onblur=feetconvert() value=0 name=feet> </FONT>FEET </TD>
        </TR>
        <TR>
          <TD>
            <FONT face="comic sans ms"><INPUT 
            onblur=inchconvert() value=1 name=inch> </FONT>INCHES</TD>
        </TR>
        <TR>
          <TD width="50%">
              <p align="center"><input type="button" value="Submit" name="B3"></p>
          </TD>
        </TR></TBODY></FORM></TABLE>
      <p align="left">
      <FONT face="Comic Sans Ms" size="3">Note: 1 Inch = 2.54 cm, 1 Feet = 30.48 cm, 1 
      Feet = 12 Inch</FONT>
      <BR>

<SCRIPT language=JavaScript>


function roundit(which){
return Math.round(which*100)/100
}

function cmconvert(){
with (document.cminch){
feet.value = roundit(cm.value/30.84);
inch.value = roundit(cm.value/2.54);
}
}

function inchconvert(){
with (document.cminch){
cm.value = roundit(inch.value*2.54);
feet.value=roundit(inch.value/12);
}
}

function feetconvert(){
with (document.cminch){
cm.value=roundit(feet.value*30.48);
inch.value=roundit(feet.value*12);
}
}

</SCRIPT>
</font>
</body>

DOWNLOAD FILE HERE

Text Field Checker Using JQuery

This program that I wrote in PHP,HTML and JQuery will check if all the required fields are being filled up by the visitor of our website. I use JQuery for checking the empty text field in our webpage I hope you will find my work useful in your web design and development.

If you find my work useful please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program


Compound Interest Solver in JavaScript

One of my favorite scripting programming language is JavaScript in this program I wrote a simple Compound Interest Solver that will solve for the interest rate for the loan made by the person. The code is very simple and easy to understand, I'm using notepad++ as my test editor in writing this program.

If you have some questions about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program


Program Listing

<!-- Written By: Jake R. Pomperada, MAED-IT  2014-->
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var princ;
var ratepc;
var years;
var rate;
var power;
function calcAmt(frm) {
princ = eval(frm.pr.value);
ratepc = eval(frm.rt.value);
years = eval(frm.yr.value);
rate = ratepc / 100;
power = Math.pow((1 + rate), years);
frm.amt.value = Math.round(princ * power * 100) / 100;
frm.inter.value = Math.round((frm.amt.value - princ) * 100) / 100;
}
function checkInput(frm) {
if (rate == 0 || rate > .3) {
window.alert ("Are you sure that the interest rate is " + ratepc +"%?");
frm.rt.focus();
}
if (years == 0 || years > 30) {
window.alert ("Are you sure that the term is " + years + " years?");
frm.yr.focus();
   }
}
//  End -->
</script>

</HEAD>


<BODY BGCOLOR="LIGHTGREEN">

<center>
<hr>
<h1> <font face="comic sans ms"> COMPOUND INTEREST SOLVER  </h1>
<hr>
<br> <br>
<font size=5>
<form method=get name=frm>
Principal <input type=text name=pr size=10 maxlength=10 onChange=calcAmt(this.form)>
Rate <input type=text name=rt size=6 maxlength=6 onChange=calcAmt(this.form)>
Years <input type=text name=yr size=5 maxlength=5 onChange=calcAmt(this.form)>
<br>
<br>
<input type=button name=calc value="Calculate" size=10 onClick=checkInput(this.form); calcAmt(this.form);>
<input type=reset value="Clear">
<br>
<br>
Amount <input type=text name=amt size=10>
Interest <input type=text name=inter size=10>
</form>
</font>
</font>
</center>
</body>
</html>


Zodiac Sign Checker in PHP

This code is being given to us by my friend named Alfredo Soliva an IT student here in the Philippines in their programming class in PHP and MySQL programming. I am very happy that some programmers and students visiting my website and sharing their codes to help our fellow programmers and software engineers.

What that program will do is to ask the user to select form the combo box the month and day and then the program will check what zodiac sign belongs the user of our program. The code uses also some JavaScript for form validations and CSS for the design of the webpage. I hope the work of our friend Alfredo gives you an idea how to program in PHP.

Thank you very much.



Sample Output of Our Program

Program Listing

index.html

<html>
<head>
<title>Activity No. 1 Zodiac Sign</title>
<style type="text/css">
body {
background:#00FFFF;
}
#header {
width: 100%;
height: 120px;
background: #202020;
text-align: center;
font-size:xx-large;
}

#zodiac {
color: #999999;
font-weight: bold;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: xx-large;
}
#zodiac:hover{
color:white;
}
#monthdate {
position:absolute;
left:40%;
top:100px;
}
#footer{
height: 40px;
border-top: 1px solid gray;
text-align: center;
font-size: 14px;
}
</style>
</head>
<body>

<div id="header">
 <h1 class="style1" id="zodiac">ZODIAC SIGN</h1>
</div>

<div id = "monthdate">
<form method = POST action = result.php>
<!-- display dropdown list for month -->
<select name="month" id="month" onChange="adlaw(this.value)">
<option value = "0" disabled = "disabled" selected = " ">Month</option>
<option value = "1">January</option>
<option value = "2">February</option>
<option value = "3">March</option>
<option value = "4">April</option>
<option value = "5">May</option>
<option value = "6">June</option>
<option value = "7">July</option>
<option value = "8">August</option>
<option value = "9">September</option>
<option value = "10">October</option>
<option value = "11">November</option>
<option value = "12">December</option>
</select>
<!-- display dropdown list for day -->
<select name = "day" id = "day">
<option value = "day" disabled = "disabled" selected = " ">Day</option>
</select>
   <input type="submit" name="btnzodiac" value="Get My Zodiac">
</form>
</div>
<div id="footer">
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p>&nbsp;</p>
 <p><br />
  &copy; 2014 Midterm Project. Alfredo Rodriguez Soliva Jr./ All rights reserved.</p>
</div>

</body>

<script type="text/javascript">

var me;
var theLeap = document.getElementById("leap"); 
var theDay = document.getElementById("day"); 
var theMonth = document.getElementById("month");
var x; 

function adlaw(me){

if(me==4 || me==6 || me==9 || me ==11){
displayday(30);
}
else if(me==1 || me==3 || me==5 || me==7 || me==8 || me==10 || me==12){
displayday(31);
}
else if(me==2){
x = prompt ("enter your choice 'Y' for leap year 'N' if not");
if (x == 'y' || x == 'Y')
{
displayday(29);
}
else if (x == 'n' || x == 'N')
{
displayday(28);
}
else
{
alert ("please make a selection");
}
}
}

function displayday(num){ 
theDay.innerHTML=""; 
for(var ctr=1;ctr<=num;ctr++){ 
theDay.innerHTML = theDay.innerHTML+'<option value='+ctr+'>'+ctr+'</option>';
}
}

</script>

</html>

result.php

<html>
<style type="text/css">
body{
background-color:#99FFFF;
font-family:Geneva, Arial, Helvetica, sans-serif;
font-size:xx-large;
text-align:center;
}
#header {
width: 100%;
height: 120px;
background: #202020;
text-align: center;
font-size:xx-large;
color:#CCCCCC;
}

#header:hover {
color:#FFFFFF
}

#body:hover {
color:white;
}

#result:hover{
color:white;
font-size:50px;
}



</style>

<body>

<div id="header">
 <h1 class="style1" id="zodiac">Your ZODIAC SIGN</h1>
</div>
<div id="result">
<?php
$month = $_POST['month'];
$day = $_POST['day'];
if (($month == '3') && ($day>21) || ($month == '4') && ($day<19)){
print 'Aries.';
} elseif (($month == '2') && ($day>20) || ($month == '3') && ($day<20)){
print 'Pisces.';
} elseif (($month == '4') && ($day>20) || ($month == '5') && ($day<20)){
print 'Taurus.';
} elseif (($month == '5') && ($day>21) || ($month == '6') && ($day<20)){
print 'Gemini.';
} elseif (($month == '6') && ($day>21) || ($month == '7') && ($day<22)){
print 'Cancer.';
} elseif (($month == '7') && ($day>21) || ($month == '8') && ($day<22)){
print 'Leo.';
} elseif (($month == '8') && ($day>23) || ($month == '9') && ($day<22)){
print 'Virgo.';
} elseif (($month == '9') && ($day>23) || ($month == '10') && ($day<22)){
print 'Libra.';
} elseif (($month == '10') && ($day>23) || ($month == '11') && ($day<22)){
print 'Scorpio.';
} elseif (($month == '11') && ($day>23) || ($month == '12') && ($day<21)){
print 'Sagittarius.';
} elseif (($month == '12') && ($day>22) || ($month == '1') && ($day<21)){
print 'Capricorn.';
} elseif (($month == '1') && ($day>19) || ($month == '2') && ($day<19)){
print 'Aquarius.';
} else {  
print 'No information available';
}
?>
</div>
</body>

</html>

DOWNLOAD FILE HERE

Tuesday, September 16, 2014

Celsius To Fahrenheit Solver in Bash

This is another conversion of temperature that I wrote using Bash script. In my previous article I wrote a program that will ask the user to enter the temperature in Fahrenheit and then it will convert to its Celsius temperature equivalent. By this time it another way around from Celsius it will convert to its Fahrenheit value.

Take note in my sample bash program I always adding some functionalities like asking the user if the user wants again to run the program so that it can give a different value and then give us the different converted values. It makes our bash script more versatile in many ways. I hope you will find my sample bash script programs more useful in your learning how to program in bash in UNIX, MAC OS and Linux environment.

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

Thank you very much.



Sample Output of Our Program

Program Listing

#!/bin/bash

# Celsius To Fahrenheit Solver
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 16, 2014

start()
{
clear
echo -e "\n"
echo -e "\t (====== CELSIUS TO FAHRENHEIT SOLVER  =====)";
echo -e "\n"

read -p  "Please Enter Temperature in Celsius : " celsius_values
compute=$(echo "scale=2;((($celsius_values * 9/5 +32)))"|bc)

echo -e "\nTemperature in Celsius is $celsius_values\xe2\x84\x83 ."
echo -e "The equivalent temperature in Fahrenheit is $compute\xe2\x84\x83."

while true; do
  echo -e "\n"
  read -p "More (Y/N)? " answer
  case $answer in
       [Yy]* ) start;  break;;
       [Nn]* ) bye; break;;
       * ) echo "Please answer yes or no. ";;
  esac
done
}

bye()
{
echo -e "\n"
echo -e "\t Thank You For Using This Program.";
echo -e "\n\n";
}

start

Fahrenheit To Celsius Solver in Bash

In this article I would like to share with you a sample program that I wrote using BASH scripting language or Bourne Again Shell in Linux operating system I called this program Fahrenheit To Celsius Solver in Bash. What the program will do when the user run the script using ./fah.sh or bash fah.sh it will ask the user to enter the temperature in Fahrenheit and the program will convert it to its Celsius equivalent.

The script is very short and very easy to understand a good way to automate some math problems using Bash as our programming language under the Linux environment. If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Sample Output of Our Program


Program Listing

#!/bin/bash

# Fahrenheit To Celsius Solver
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 16, 2014

start()
{
clear
echo -e "\n"
echo -e "\t (====== FAHRENHEIT TO CELSIUS SOLVER  =====)";
echo -e "\n"

read -p  "Please Enter Temperature in Fahrentheit : " fah
compute=$(echo "scale=2;((($fah -32) * 5) / 9)"|bc)

echo -e "\nTemperature in Fahreneit is $fah\xe2\x84\x83 ."
echo -e "The equivalent temperature in Celsius is $compute\xe2\x84\x83."

while true; do
  echo -e "\n"
  read -p "More (Y/N)? " answer
  case $answer in
       [Yy]* ) start;  break;;
       [Nn]* ) bye; break;;
       * ) echo "Please answer yes or no. ";;
  esac
done
}

bye()
{
echo -e "\n"
echo -e "\t Thank You For Using This Program.";
echo -e "\n\n";
}

start

DOWNLOAD FILE HERE

Friday, September 5, 2014

Prime Number Checker in Bash

I'm still learning how to program in Bash or Bourne Again Script that is very useful in system administration in Unix or Linux operating system. There is already some improvements in my understanding how to create different types of script using Bash. Indeed learning Bash scripting programming is a wonderful journey that everyone that is interested will truly enjoy.

In this article I would like to share with you a simple script that will check if the given number by the user is a prime number or not. First thing we must able to understand what is really a prime number. A prime number an be divided evenly only by 1, or itself. And it must be a whole number greater than 1 there are many examples of  prime number one example is 3 that can divided evenly by 1 and itself the same with 5,7,11,13,17,19 and so on and so forth. An example of number that is not a prime number is 8 that is very divisible by 2,4.

I hope you will find my sample bash script useful in your learning bash programming. If you have some questions feel free to send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Sample Output of Our Program


Nano Text Editor used in writing this program

 
Program Listing

#!/bin/bash

# Prime Number Checker
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 5, 2014 Friday


echo -e "\n"
echo -e "\t (====== PRIME NUMBER  CHECKER =====)";
echo -e "\n"

read -p  "Kindly enter a number : " number
echo -e "\n"

a=2
b=0

while [ $a -lt $number ];
 do
   solve=$(($number % $a))

  if [[ $solve -eq $b ]]; then
       echo " The $number is NOT a PRIME NUMBER."
       echo -e "\n"
       exit
  else
    a=$(($a+1))
  fi
done
       echo " The $number is a PRIME NUMBER."
       echo -e "\n"

DOWNLOAD FILE HERE

Thursday, September 4, 2014

Leap Year Checker in Bash

In this article I would like to share with you a simple bash script that I wrote to check if the given year by the user is a leap year or not a leap year. In order for us to understand leap year occurs every four years just like the Olympic games examples of leap year are 1988, 2000, 2004, 2008 and etc. 

The formula in bash script in checking for leap year is a=$(($year % 4)) in this expression we assign a variable a to check if the given year that is being stored in variable year has a remainder of 4. The operator we use to check of remainder is % also known as modulo. If assignment operator a is equal to without any remainder in the given year that year will become a leap year. In addition our script will allow the user to repeat the program running by asking the user if the user would like to run the program again or not. What is good about this script it checks if the response of the user to run the program is valid or not valid it makes our script more secure in accepting only valid response from our user.

I hope you will find our program useful in your learning how to write bash script in Linux and Unix operating system. If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.



Sample Output of Our Program


The nano text editor used in writing our script.


Program Listing

#!/bin/bash

# Leap Year Checker
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 4, 2014 Thursday

start()
{
echo -e "\n"
echo -e "\t (====== LEAP YEAR CHECKER =====)";
echo -e "\n"

read -p  "Please enter a year : " year
echo -e "\n"

a=$(($year % 4))
b=$(($year % 100))
c=$(($year % 400))


if [[ $a == 0 || $b == 0 || $c == 0 ]]; then
   echo "The $year is a Leap Year."
else
   echo  "The $year is Not a Leap Year"
fi
while true; do
  echo -e "\n"
  read -p "More (Y/N)? " answer
  case $answer in
       [Yy]* ) start;  break;;
       [Nn]* ) bye; break;;
       * ) echo "Please answer yes or no. ";;
  esac
done
}

bye()
{
echo -e "\n"
echo -e "\t Thank You For Using This Program.";
echo -e "\n\n";
}

start

DOWNLOAD FILE HERE

 


Wednesday, September 3, 2014

Even and Odd Number Checker in Bash

In this article I would like to share with you a simple program that uses BASH or Bourne Again Shell in Linux operating system I called this program Odd and Even number Checker.  What this program will do is to ask the user to enter a number and then the program will check and determine if the number odd or even number. What is good about this program is that after the program determine the number whether it is even or odd number. The program will ask the user to continue using the program or not if the user choose y for yes the program will run again, if no the program will terminate and will return to command line.

If hope you will find my work useful in learning how to program using Bash scripting language in Linux, Unix or others distributions. If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

Thank you very much.


Nano text editor is used in writing the bash program


Change File Permission and Running our Bash Script Program



Sample Output of Our Program


Program Listing

#!/bin/bash

# Odd and Even Number Checker
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 3, 2014

start()
{
clear
echo -e "\n"
echo -e "\t (====== ODD AND EVEN NUMBER CHECKER =====)";
echo -e "\n"

read -p  "Please enter a number : " number
echo -e "\n"

check_number=$(($number % 2))

if [ $check_number == 0 ]; then
   echo "$number is an even number."
else
   echo  "$number is an odd number."
fi
while true; do
  echo -e "\n"
  read -p "More (Y/N)? " answer
  case $answer in
       [Yy]* ) start;  break;;
       [Nn]* ) bye; break;;
       * ) echo "Please answer yes or no. ";;
  esac
done
}

bye()
{
echo -e "\n"
echo -e "\t Thank You For Using This Program.";
echo -e "\n\n";
}

start

Addition of Five Numbers in Bash

One of the interesting aspects of open source software is that we can explore different types of tools and programming languages that can help us in our everyday work. When I started learning Linux way back in 2010 I can say it is a different experience first time in my life I was able to learn an operating system that is free, open source, stable and best of all has many built in functions that cannot be found in windows operating system. At first I found myself in a difficult situation because of lacking of experience in Linux and there are only few books written on that particular subjects. The biggest hindrance for beginners like me how to learn the rules in using Linux in everyday computing activities.

The best advice that I get actually is the forum that I read in the Internet the journey in Linux or Unix operating system is a step by step process. Read a lot from blogs, tutorials and articles in the Internet and do some example activities in your computer by installing virtual machine or install the full installation of the operating in your computer. It takes a lot of courage and confidence to learn something new in this ever changing world of Information Technology. By persistence, hard work and patience your effort spend in learning Linux is a worth while.

In this article I would like to share with you my avid reader of my blog of the simplest script that I have written using BASH script of Bourne Again Shell I called this program addition of five numbers. What the program will do is to ask the user to enter five numbers and then it will compute for the sum of five numbers being given by our user. I am using Ubuntu 14.04 as my Linux distribution, I try to improve myself in the aspect of scripting programming using BASH because it is very useful in system administration of networks.

If you find my work useful let me know kindly send me an email at jakerpomperada@yahoo. com and jakerpomperada@gmail.com.

Thank you very much.

 Nano text editor used in writing this BASH script.


Change File Permission and Running our BASH script.

Sample Output of Our Program


Program Listing

#!/bin/bash

# addition.sh
# addition of five numbers in bash
# written by: Mr. Jake  R. Pomperada, MAED-IT
# tools : Ubuntu 14.04
# date  : September 03, 2014

clear
echo -e "\n"
echo -e "\t (===== Addition of Five Numbers =====)"
echo -e "\n"
read -p  "Enter First Number   :  " a
read -p  "Enter Second Number  :  " b
read -p  "Enter Third Number   :  " c
read -p  "Enter Fourth Number  :  " d
read -p  "Enter Fifth Number   :  " e

sum=$(expr "$a" + "$b" + "$c" + "$d" + "$e")

echo -e "\n"
echo "The sum of  $a, $b, $c, $d and $c is $sum.";
echo -e "\n"
echo -e "\t Thank you for using program."
echo -e "\n"