Thursday, October 29, 2015

Payroll in JavaScript

A simple payroll program that I wrote in JavaScript to compute the salary of the employee. The code is very simple and easy to understand.

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>Swapping of Numbers</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    
var val_1 = parseInt(prompt("Enter First Value : "));
var val_2 = parseInt(prompt("Enter Second Value : "));
    var temp=0;
document.write("<h3> Swapping of Numbers</h3>");
document.write("<h3> BEFORE SWAPPING </h3>");
document.write("<font face='arial' size='3'>");
    document.write(" First Value    : " + val_1 + ".</font><br>");
document.write("<font face='arial' size='3'>");
    document.write(" Second Value   : " + val_2 + ".</font><br>");
 
temp = val_1;
     val_1 = val_2;
     val_2 = temp;
               
    document.write("<h3> AFTER SWAPPING</h3>");
document.write("<font face='arial' size='3'>");
    document.write(" First Value      : " + val_1 + ".</font><br>");
document.write("<font face='arial' size='3'>");
    document.write(" Second Value     : " + val_2 + ".</font><br>");

document.write("<h3> End of Program </h3>");
</script>
</body>

</html>

Swapping of Two Numbers in JavaScript

This sample program will ask the user to enter two numbers and then our program will enter change the arrangement of two numbers.

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>Swapping of Numbers</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    
var val_1 = parseInt(prompt("Enter First Value : "));
var val_2 = parseInt(prompt("Enter Second Value : "));
    var temp=0;
document.write("<h3> Swapping of Numbers</h3>");
document.write("<h3> BEFORE SWAPPING </h3>");
document.write("<font face='arial' size='3'>");
    document.write(" First Value    : " + val_1 + ".</font><br>");
document.write("<font face='arial' size='3'>");
    document.write(" Second Value   : " + val_2 + ".</font><br>");
 
temp = val_1;
     val_1 = val_2;
     val_2 = temp;
               
    document.write("<h3> AFTER SWAPPING</h3>");
document.write("<font face='arial' size='3'>");
    document.write(" First Value      : " + val_1 + ".</font><br>");
document.write("<font face='arial' size='3'>");
    document.write(" Second Value     : " + val_2 + ".</font><br>");

document.write("<h3> End of Program </h3>");
</script>
</body>
</html>

Pound To Kilogram Converter in JavaScript

A simple program that I wrote that will ask the user to enter a value in pound and it will convert into kilogram weight equivalent. The program is very simple and easy to understand.

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>Pound To Kilogram Converter</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    var pound = parseInt(prompt("How Many Pound(s) : "));
var solve_kilogram=(pound * 0.453592);

document.write("<h3> Pound To Kilogram Converter</h3>");
document.write("<font face='arial' size='4'>");
    document.write(" The equivalent  of " + pound + " pound(s)");
document.write(" is " + solve_kilogram.toFixed(2) + " kilogram(s).</font><br>");
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>

Yard To Feet Converter in JavaScript

A simple program that I wrote in JavaScript that will ask the user to enter how many yards and then our program will covert the value given by the user in yard into its feet equivalent.

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>Yard To Feet Converter</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    var yard = parseInt(prompt("How Many Yards : "));
var solve_feet=(yard * 3);

document.write("<h3> Yard To Feet Converter</h3>");
document.write("<font face='arial' size='4'>");
    document.write(" The equivalent  of " + yard + " yard(s)");
document.write(" is " + solve_feet + " feet(s).</font><br>");
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>

Odd and Even Number Generator in JavaScript

This sample program that I wrote in JavaScript will show you how to create and use one dimensional array as your data structure to accept input values. I called this program Odd and Even Number Generator what does the program will do is to ask the user to give a series of numbers and then our program will enumerate and classify the odd and even number provided by our 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

<html>
 <head>
 <title> Even and Odd Number Generator </title>
 </head>
 <body>
 <h1> Even and Odd Number Generator </h1>
 <script>
    var grades = [];
    var i=0;
          for (i = 0; i < 10; i++) {
            grades.push(parseInt(prompt("Enter a value in item no. " + (i + 1))));
          }
 document.write("LIST OF EVEN NUMBERS");
 document.write("<br><br>");
 for (i = 0; i < 10; i++) {
  if (grades[i] % 2 == 0){
  document.write(grades[i] + "<br>");
}
     }
 
 document.write("LIST OF ODD NUMBERS");
 document.write("<br><br>");
 for (i = 0; i < 10; i++) {
  if (grades[i] % 2 != 0){
  document.write(grades[i] + "<br>");
}
     }
   
</script>
</body>
</html>
 

Input and Output Using Two Dimensional Array in JavaScript

As my journey in learning JavaScript programming continues I stumble on the idea how to use two dimensional array in JavaScript doing my research on the language itself I discovered JavaScript does not have it's own structure on two dimensional array or multi dimensional array as its data structure but creating two dimensional array is much easier and enjoyable learning experience on my part. 

In this sample program will demonstrate to you how the basic input and output can be done using two dimensional array in JavaScript the code is very short and very simple I intended my work for beginners like me. I hope you will find my work useful.

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

<html>
<body>
<script>
var arr  = [];

name = prompt("Enter your name");
age  = Number(prompt("Enter your age "));
var arr1 = [name,age];

arr.push(arr1);

document.write("Name : " +arr[0][0] + "<br>");
document.write("Age  : " +arr[0][1]);

</script>
</body>
</html>

Addition of Three Numbers Using Two Dimensional Array Using JavaScript

JavaScript is one of the hottest programming language now a days because of the intensive use of the Internet it is very seldom to see a website that does not use JavaScript in one way to another to make a website more interactive. In this article I would like to share with you another program that I wrote to understand the concept of two dimensional array in JavaScript.

Technically speaking JavaScript does not have a two or multidimensional array as data structure it only relies on one dimensional array but surprisingly creating two dimensional array in JavaScript is very easy. The sample program that I will share is an addition of three numbers using two dimensional array in JavaScript. I hope you will find my work useful and learn from it.

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

<html>
<body>
<style>
h3 {
   font-family:arial;
   };
 </style>
<script>
var arr  = [];

val1 = Number(prompt("Enter First Value :"));
val2 = Number(prompt("Enter Second Value : "));
val3 = Number(prompt("Enter Third Value : "));

var arr1 = [val1,val2,val3];

arr.push(arr1);

a = arr[0][0];
b = arr[0][1];
c = arr[0][2];

var solve_add = (a+b+c);

document.write("<h3> Addition of Three Numbers Using Two Dimensional Array </h3>");
document.write("<font face='arial' size=4>Value store ");
document.write("in variable A is " + a + ".</font><br>");
document.write("<font face='arial' size=4>Value store ");
document.write("in variable B is " + b + ".</font><br>");
document.write("<font face='arial' size=4>Value store ");
document.write("in variable C is " + c + ".</font><br>");
document.write("<br>");
document.write("<font face='arial' size=4>The sum of " + a );
document.write(" , " + b + " and " + c + " is " + solve_add + ".");
</script>
</body>
</html>

Nested Loop in JavaScript

In this article I would like to share with you how to write a nested loop in JavaScript using For loop statement. A nested loop is a loop in another loop this kind of looping structure is very useful in some programming problems for example creating a multiplication table we need this one for row and column.

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


<html>
    <head>
        <title> Nested Loop in JavaScript</title>
    <head>
        
    <body      
        <h1> Nested Loop in JavaScript </h1>
        <script>
           for(var x =1; x<=10; x++) {
               document.write(x);
               document.write("<br>");
            }
            
            document.write("<br>");
            
            for (var row = 1; row <= 200; row++) {
                for (var column = 1; column <= 200; column++) {
                    document.write("*   ");
                    
                }
                
                document.write("<br>");
            }
        </script>
</body>
</html>

Friday, October 23, 2015

Area of the Square Using JavaScript

A simple program that I wrote in JavaScript will compute the area of the square using JavaScript. The program is very simple to understand and ideal for beginners in JavaScript 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

<html>
<head>
  <title>Area of Square</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    var side = parseFloat(prompt("Enter Side of the Square : "));
 
    var solving_area = (side * side);
 
document.write("<br>");
document.write("<h3> Area of Square</h3>");
document.write("<font face='arial' size='3'>")
    document.write(" The Sides of the Square is " + side + ".</font><br>");
document.write("<font face='arial' size='3'>")
    document.write(" The Area of the Square is " + solving_area + ".</font><br>");
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>

Area of Triangle in JavaScript

A sample program that I wrote in JavaScript that will calculate the area of the triangle based on the values being provided 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.


Sample Program Output


Program Listing

<html>
<head>
  <title>Area of Triangle</title>
</head>
<style>
h3 {
   font-family:arial;
   };
</style>
<body>
  <script>
    
var base = parseInt(prompt("Enter width of Triangle : "));
var height = parseInt(prompt("Enter height of Triangle : "));
   
    var solving_triangle = (base * height)/2;
 
document.write("<br>");
document.write("<h3> Area of Triangle</h3>");
document.write("<font face='arial' size='3'>")
    document.write(" The Width of Triangle is " + base + ".</font><br>");
document.write("<font face='arial' size='3'>")
    document.write(" The Height of Triangle is " + height + ".</font><br><br>");
    document.write("<font face='arial' size='3'>")
    document.write(" The Area of Triangle is " + solving_triangle + ".</font>");
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>

Reverse a Number in JavaScript

A sample program in JavaScript that I wrote that will ask the user to enter a number and then our program will reverse the arrangement of numbers 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.


Sample Program Output


Program Listing

<html>
<head>
  <title>Reverse a Number </title>
</head>
<style>
h3 {
   font-family:arial;
   };
   
 </style>
<body>
  <script>
    
    var reverse_number =0;
var num_value = parseInt(prompt("Enter number: "));

document.write("<br>");
document.write("<h3> Reverse a Number</h3>");
    document.write("<font face='arial' size='3'>");
    document.write("The Original Number is  " + num_value + " .</font> <br>");
    
      while( num_value != 0 )
      {
          reverse_number = parseInt(reverse_number * 10);
          reverse_number = parseInt(reverse_number + (num_value%10));
          num_value = parseInt(num_value/10);
      }
 
      document.write("<font face='arial' size='3'>");
      document.write("The Reverse Number is  " + reverse_number + " .</font> <br>");
      document.write("<h3> End of Program </h3>");
</script>
</body>
</html>


Number Palindrome in JavaScript

This program that I wrote in JavaScript will ask the user to enter a number and then our program will check and determine if the given number by the user is a palindrome or not a palindrome.

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>Number Palindrome </title>
</head>
<style>
h3 {
   font-family:arial;
   };
 </style>
<body>
  <script>
    
var num_value = (prompt("Enter number: "));
var rev_number = "";
var b = num_value.length;
document.write("<br>");
document.write("<h3> Number Palindrome</h3>");
     
 for(var a=b; a>=0; a--)
    {
    rev_number = rev_number+num_value.charAt(a);
    }
 
   if ( num_value==rev_number){
      document.write("<font face='arial' size='3'>");
      document.write(num_value + " is a Palindrome Number. </font> <br>");
 }
   else 
     {
 document.write("<font face='arial' size='3'>");
      document.write(num_value + " is a not Palindrome Number. </font> <br>");
     }  
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>



Floyd's Triangle in JavaScript

A simple program that I wrote the will generate the Floy'ds Triangle using JavaScript.

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

<head>
  <title>Floyd's Triangle </title>
</head>
<style>
h3 {
   font-family:arial;
   };
 </style>
<body>
  <script>
    
    var rows=0, number = 1, counter=0, j=0;
var num_value = parseInt(prompt("Enter number: "));

document.write("<br>");
document.write("<h3> Floyd's Triagle</h3>");
     for ( counter = 1 ; counter <= num_value; counter++ )
       {
           for ( j = 1 ; j <= counter ; j++ )
           {
                
                document.write("<font face='arial' size='3'>");
                document.write(" " + number + " </font>");
number++;
           }
           document.write("<br>");
       }
      document.write("<h3> End of Program </h3>");
</script>
</body>
</html>