Sunday, December 11, 2016

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>








Armstrong Number Checker in C#

Today I would like to share with you guys a program that is written by a close friend of mind, a fellow software engineer and expert C# developer Mr. Alfel Benvic G. Go he wrote this program we called Armstrong Number Checker using C#. First of all thank you Sir Bon for sharing this program to us. What does the program will do is to ask the user to give a number and then our program will compute the armstrong number based on the given number by our user. Thank you once again Sir Bon for sharing your codes to us.

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArmstrongNumber
{
    /*Armstrong number is a number which is equal to sum of digits raise to the power total number of digits in the number. */
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter a Number: ");
            String a = Convert.ToString(Console.ReadLine());
            Int32 size = a.Length;

            Console.WriteLine("Length of the Input Number is = " + size);
            Console.WriteLine("\n");
            Int32 num = Int32.Parse(a);
            Int32 n = num;
            Int32 check = 0, remainder;

            while (num > 0)
            {
                remainder = num % 10;
                check = check + (Int32)Math.Pow(remainder, size);
                num = num / 10;
            }
            if (check == n)
                Console.WriteLine(n + " is an Armstrong Number");
            else
                Console.WriteLine(n + " is not an Armstrong number");
            Console.ReadLine();
        }
    }
}



Pascal Triangle in C#

Today I would like to share with you guys a program that is written by a close friend of mind, a fellow software engineer and expert C# developer Mr. Alfel Benvic G. Go he wrote this program we called Pascal Triangle using C#. First of all thank you Sir Bon for sharing this program to us. What does the program will do is to ask the user to give a number and then our program will generate the corresponding pascal triangle pattern in  C#. I hope you will find the work of Sir Bon 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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PascalTriangle
{
    class Program
    {
        static void Main(string[] args)
        {
            Int32 bin;
            Int32 p;
            Int32 q;
            Int32 r;
            Int32 x;

            Console.Write("Enter No of Rows: ");
            r = Convert.ToInt32(Console.ReadLine());
            bin = 1;
            q = 0;


            while (q < r)
            {
                for (p = 40 - 3 * q; p > 0; p--)
                    Console.Write(" ");
                for (x = 0; x <= q; x++)
                {
                    if ((x == 0) || (q == 0))
                        bin = 1;
                    else
                    bin = (bin * (q - x + 1)) / x;
                    Console.Write("      ");
                    Console.Write(bin);
                }
                Console.WriteLine("");
                q++;
            }
            Console.ReadLine();
        }
    }
}



Palindrome Checker in C#

In this article I would like to share with you a simple program that will ask the user to give a word or a string and then our program will check if the given word or a string is a palindrome or not a palindrome. I am using C# as my programming language in this sample program. 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

using System;

namespace palindrome_checker
{
    class palindrome_check
    {
        static void Main(string[] args)
        {
            string string_given, reverse_string = "";
            string string_upper;
            Console.Write("\n\n");
            Console.Write("\t    Palindrome Checker in C#");
            Console.Write("\n\n\n");
            Console.Write("\tGiven Any Word or String : ");
            string_given = Console.ReadLine();
            for (int a = string_given.Length - 1; a >= 0; a--) 
            {
                reverse_string += string_given[a].ToString();
            }

            string_upper = reverse_string.ToUpper();

            if (reverse_string == string_given)
            {
                Console.Write("\n\n");
                Console.WriteLine("\tThe given word or a string {0} is a Palindrome.",string_upper);
            }
            else
            {
                Console.Write("\n\n");
                Console.WriteLine("\tThe given word or a string {0} is Not a Palindrome.",string_upper);
            }
            Console.Write("\n\n");
            Console.Write("\tThank You For Using This Software.");
            Console.Write("\n\n");
            Console.ReadKey();
        }
    }
}





Factorial Solver in C#

To all my visitors and followers of my website thank you for visiting even though I'm not earning any money here but still I want to spread the message to share the knowledge in computer programming to all. Anyway in this article I would like to share with you a sample program that I used using C# to accept a number from our user and then our program will compute the factorial equivalent of the given number by our user. The code is very short 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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace factorial
{
    class factorial
       { 
           /* Program : Factorial Solver                       */
           /* Author  : Mr. Jake R. Pomperada, MAED-IT         */
           /* Date    : Noverber 26, 2016  Saturday  10:59  AM  */
           /* Tools   : C#                                     */

        static void Main(string[] args)
        {
            int num=0, a=0, fact = 1;
            Console.Write("\n\n");
            Console.Write("  ===== FACTORIAL SOLVER ===== ");
            Console.Write("\n\n");
            Console.Write("Give a Number : ");
            num = int.Parse(Console.ReadLine());
            for (a= num; a >= 2; a--){
                fact *= a;
            }
            Console.Write("\n\n");
            Console.Write("The Factorial Values of {0} is {1}.", num, fact);
            Console.Write("\n\n");
            Console.Write("  End of Program ");
            Console.Write("\n\n");
            Console.ReadLine();
        }
    }
}







Saturday, December 3, 2016

Fractional Knapsack Algorithm in C#

Hi there in this article I would like to share with you the code that is written by a close friend of mine, a fellow software engineer and Expert C# developer Mr. Alfel Benvic G. Go. Thank you very much Sir Bon for sharing your code in your website to share the knowledge to other developers around the world.  


In this article Sir Bon share his sample program that is called Fractional Knapsack Algorithm written entirely in C# programming language.

According to Wikipedia.org Factional Knapsack Program is defined as In theoretical computer science, the continuous knapsack problem (also known as the fractional knapsack problem) is an algorithmic problem in combinatorial optimization in which the goal is to fill a container (the "knapsack") with fractional amounts of different materials chosen to maximize the value of the selected materials. It resembles the classic knapsack problem, in which the items to be placed in the container are indivisible; however, the continuous knapsack problem may be solved in polynomial time whereas the classic knapsack problem is NP-hard.[1] It is a classic example of how a seemingly small change in the formulation of a problem can have a large impact on its computational complexity.

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