Sunday, December 11, 2016

Palindrome Checker in JavaScript

In this article I wrote in JavaScript that will ask the user to give a string or a word and then the program will check and determine if the given word or string is a palindrome or not a palindrome.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<body bgcolor="yellow">

<script type="text/javascript">
  function Palindrome() {
   var revStr = "";
   var str = document.getElementById("str").value;
   var i = str.length;
   for(var j=i; j>=0; j--) {
      revStr = revStr+str.charAt(j);
   }
   if(str == revStr) {
      alert(str.toUpperCase() + " is Palindrome");
   } else {
      alert(str.toUpperCase() + " is not a Palindrome");
   }
}
</script>
<font color="blue" size="6">
 <center>
Palindrome Checker 1.0 <br>
<font size="3">
Created By <br>
Mr. Jake R. Pomperada, MAED-IT
</center>
 <br>
</font>

<form >
<font color="blue" size="4">
  Enter a Word or a Number: <input type="text" id="str" name="string" /><br />
  <br>
  <input type="submit" value="Check For Palindrome" onclick="Palindrome();"/>
</font>
</form>

</body>
</html>





Odd and Even Number Checker in JavaScript

Here is a program that I wrote using JS or JavaScript to ask the user to give a number then our program will check and determine if the given number is ODD and EVEN number.  

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

<html>
<body bgcolor="gray">

<script type="text/javascript">
  function odd_even() {
   
   var val = document.getElementById("num").value;
     n = parseInt(val);
if (isNaN(n))
{
alert("Please Enter a Number");
}
else if (n == 0)
{
alert("The number is zero");
}
else if (n%2)
{
alert("The number is odd");
}
else
{
alert("The number is even");
}
}
</script>
<font color="white" size="6">
 <center>
Odd And Even Number Checker 1.0 <br>
<font size="3">
Created By <br>
Mr. Jake R. Pomperada, MAED-IT
</center>
 <br>
</font>

<form >
<font color="white" size="4">
  Please Enter a Number <input type="text" id="num" name="number" /><br />
  <br>
  <input type="submit" value="Check Number" onclick="odd_even();"/>
</font>
</form>

</body>
</html>





Fahrenheit To Celsius Converter in JavaScript

Here is a sample program that I wrote in JavaScript that will ask the user to give temperature in Fahrenheit and then convert into Celsius equivalent.  The code is very simple and easy to understand.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

<html>
<title> Fahrenheit To Celsius Converter 1.0
</title>
<body bgcolor="lightblue">
<font color="black" face="Arial" size="5">
<center>
<br>
 Fahrenheit To Celsius Converter 1.0
<br>
</center>
</font>
<style type="text/css">
.labelText {
 text-align : right;
 padding-right : 3px;
 color   : black;
 font-family:"Arial";
 font-size    : 18px;
}
</style>

 <form  name="temp" method="post">
<table>
<tr>
<tr>
 <td> &nbsp; </td>
 </tr>
<td class="labelText">  Enter Temperature in Fahrenheit

</td>
<td> <input type="text" name="fahr"  size="10"/> </td>
</tr>

 <tr>
 <td> &nbsp; </td>
 </tr>
</td>
<tr>
<td class="labelText">
The result is
</td>
<td> 
<input type="text" name="display"  size="50"/> </td>
 </tr>
  <tr>
 <td> &nbsp; </td>
 </tr>
</td>                   
<td> <input type="button" value="Compute" 
title="Click here to compute the temperature in celsius."
 onClick="compute1()">
</td> 
<td> <input type="button" value="Clear" 
title="Click here to clear the text box."
 onClick="clear_all()">
</td> 

</table>
</font>
</form>
<script language ="javascript">
function compute1()
{
var xval1, solve1,final_result;
var result;
  
value1 = parseInt(document.temp.fahr.value);
              
solve1 = 100/(212-32) * (value1 - 32 )
// For two decimal places convertion
 final_result = Math.round(solve1 * 100) /100;

result = value1 + " fahrenheit is equivalent to " 
               + final_result + " celsius. ";

document.temp.display.value = result;
}

function clear_all()
{
document.temp.fahr.value = "";
document.temp.display.value = "";
document.temp.fahr.focus(); 
}
</script>
</body>
</html>






Area of Rectangle Solver in JavaScript

In this article I would like to share with you a sample program to solve the area of the rectangle using JavaScript. The code is very short and easy to understand I wrote this code using the time I am still working as a college IT instructor.  I hope you will find my work useful. Thank you.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<title> Area of a Rectangle Solver 1.0
</title>
<body bgcolor="yellow">
<font color="blue" face="Comic Sans MS" size="5">
<center>
<br>
Area of a Rectangle Solver 1.0   
<br>
</center>
</font>
<style type="text/css">
.labelText {
 text-align    : right;
 padding-right : 3px;
 color         : blue;
 font-family   :"Comic Sans MS";
 font-size     : 18px;
}             
</style>

 <form  name="rectangle" method="post">
<table>
<tr>
<tr>
 <td> &nbsp; </td>
 </tr>
<td class="labelText">  Enter the Width 

</td>
<td> <input type="text" name="width"  size="10"/> </td>
</tr>
 <td class="labelText">  Enter the Height

</td>
<td> <input type="text" name="height"  size="10"/> </td>
</tr>
 <tr>
 <td> &nbsp; </td>
 </tr>
</td>
<tr>
<td class="labelText">
The area of the rectangle is
</td>
<td> 
<input type="text" name="display"  size="10"/> </td>
 </tr>
  <tr>
 <td> &nbsp; </td>
 </tr>
</td>                   
<td> <input type="button" value="Compute" 
title="Click here to compute the area of the rectangle."
 onClick="compute1()">
</td> 
<td> <input type="button" value="Clear" 
title="Click here to clear the text box."
 onClick="clear_all()">
</td> 

</table>
</font>
</form>
<script language ="javascript">
function compute1()
{
var xwidth, xheight, solve;

  
xwidth = parseInt(document.rectangle.width.value);
xheight = parseInt(document.rectangle.height.value);
solve = ( xwidth * xheight);

result = solve+ ".";

document.rectangle.display.value = result;
}

function clear_all()
{
document.rectangle.width.value = "";
document.rectangle.height.value = "";
document.rectangle.display.value = "";
document.rectangle.width.focus(); 
}
</script>
</body>
</html>




Area of the Circle Solver in JavaScript

In this article I would like to a share with you guys a simple program that will ask the use give the area of the circle and then our program will compute the area of the circle using JavaScript as our programming language.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


<html>
<title> Area of a Circle Solver 1.0
</title>
<body bgcolor="lightgreen">
<font color="red" face="Arial" size="5">
<center>
<br>
Area of a Circle Solver 1.0   
<br>
</center>
</font>
<style type="text/css">
.labelText {
 text-align : right;
 padding-right : 3px;
 color   : red;
 font-family:"Arial";
 font-size    : 18px;
}
</style>

 <form  name="circle" method="post">
<table>
<tr>
<tr>
 <td> &nbsp; </td>
 </tr>
<td class="labelText">  What is the area of the circle

</td>
<td> <input type="text" name="area"  size="10"/> </td>
</tr>

 <tr>
 <td> &nbsp; </td>
 </tr>
</td>
<tr>
<td class="labelText">
The result is
</td>
<td> 
<input type="text" name="display"  size="50"/> </td>
 </tr>
  <tr>
 <td> &nbsp; </td>
 </tr>
</td>                   
<td> <input type="button" value="Compute" 
title="Click here to compute the area of the circle."
 onClick="compute1()">
</td> 
<td> <input type="button" value="Clear" 
title="Click here to clear the text box."
 onClick="clear_all()">
</td> 
 
</table>
</font>
</form>
<script language ="javascript">
function compute1()
{
var xval1, solve1,final_result;
var result;
  
value1 = parseInt(document.circle.area.value);
              
solve1 = (3.14159 * value1 * value1);
// For two decimal places convertion
final_result = Math.round(solve1 * 100) /100;

result = value1 + " radius is equivalent to " 
               + final_result + " area of the circle. ";

document.circle.display.value = result;
}

function clear_all()
{
document.circle.area.value = "";
document.circle.display.value = "";
document.circle.area.focus(); 
}
</script>
</body>
</html>



Kilometers To Miles Converter in JavaScript

Here is a sample program that I wrote a long time ago during the time I work as IT instructor in college. This program will ask the user to give a number in kilometers and then our program will convert the given number into miles equivalent using JavaScript.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<title> Kilometers to Miles Converter 1.0
</title>
<body bgcolor="black">
<font color="white" face="Arial" size="5">
<center>
<br>
   Kilometers to Miles Converter 1.0
<br>
</center>
</font>
<style type="text/css">
.labelText {
 text-align : right;
 padding-right : 3px;
 color   : white;
 font-family:"Arial";
 font-size    : 18px;
}
</style>

 <form  name="kilo" method="post">
<table>
<tr>
<tr>
 <td> &nbsp; </td>
 </tr>
<td class="labelText">  Enter Number of Kilometers

</td>
<td> <input type="text" name="distance"  size="10"/> </td>
</tr>

 <tr>
 <td> &nbsp; </td>
 </tr>
</td>
<tr>
<td class="labelText">
The result is
</td>
<td> 
<input type="text" name="display"  size="50"/> </td>
 </tr>
  <tr>
 <td> &nbsp; </td>
 </tr>
</td>
<td> <input type="button" value="Compute" 
title="Click here to compute the miles equivalent."
 onClick="compute1()">
</td> 
<td> <input type="button" value="Clear" 
title="Click here to clear the text box."
 onClick="clear_all()">
</td> 

</table>
</font>
</form>
<script language ="javascript">
function compute1()
{
var xval1, solve1,final_result;
var result;
  
value1 = parseInt(document.kilo.distance.value);
              
solve1 = (value1 * 0.621371192);
// For two decimal places convertion
final_result = Math.round(solve1 * 100) /100;

result = value1 + " kilometers(s) is equivalent to " 
               + final_result + " miles(s). ";

document.kilo.display.value = result;
}

function clear_all()
{
document.kilo.distance.value = "";
document.kilo.display.value = "";
document.kilo.distance.focus(); 
}
</script>
</body>
</html>








Addition of Two Numbers in JavaScript

Here is a sample program that I wrote a very long time ago while I'm teaching web programming in college. The program will ask the user to give two numbers and our program will find the sum of two numbers using JavaScript I am using HTML forms to accept values from the user.  I hope you will find my work useful. Thank you.

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

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<title> Sum of Two Numbers
</title>
<body bgcolor="lightgreen">
<font color="black" face="Arial" size="5">
<center>
<br>
Sum of Two Numbers
<br>
</center>
</font>
<style type="text/css">
.labelText {
 text-align : right;
 padding-right : 3px;
}
</style>
<form  name="addval" method="post">
<font color="black" face="Arial" size="5">
<table>
<tr>
<td class="labelText">  Enter Value No. 1
</td>
<td> <input type="text" name="val1"  size="10"/> </td>
</tr>
<tr>
<td class="labelText">  Enter Value No. 2
</td>
<td> <input type="text" name="val2" size="10"/> </td>
</tr>
 <td> &nbsp; </td>
<tr>
<td class="labelText">  The Total Sum is
</td>
<td> <input type="text" name="sum" size="10"/> </td>
</tr>
 <tr>
 <td> &nbsp; </td>
 </tr>
<td> <input type="button" value="Compute" 
title="Click here to find the sum."
 onClick="add()">
</td> 
<td> <input type="button" value="Clear" 
title="Click here to clear the text box."
 onClick="clear_all()">
</td> 

</table>
</font>
</form>
<script language ="javascript">
function add()
{
var xval1, xval2, xsum;
  
xval1 = parseInt(document.addval.val1.value);
xval2 = parseInt(document.addval.val2.value);

xsum = (xval1 + xval2);

document.addval.sum.value = xsum;
}

function clear_all()
{
document.addval.val1.value = "";
document.addval.val2.value = "";
document.addval.sum.value = "";
document.addval.val1.focus(); 
}
</script>
</body>
</html>