Friday, February 2, 2018

Longest String in JavaScript

A simple program that will ask the user to give a sentence and then our program will check which of the words in the given sentence is the longest in terms of number of characters. I wrote this program using sublime as my text editor and JavaScript as my programming language.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.




Sample Program Output


Program Listing

index.htm

<!--
 Written By Mr. Jake R. Pomperada, MAED-IT
 February 2, 2018   11:54 AM   Friday
 Bacolod City, Negros Occidental Republic of the Philippines
 jakerpomperada@yahoo.com and jakerpomperada@gmail.com -->
<!doctype html>
<html>
<head>
<title> Longest String in JavaScript </title>
<style>

   .art {

      font-family: arial;
      font-weight: bold;
      color:red;
      text-align: center;
      width:45%;
      background-color:yellow;
   }

.art2 {

      font-family: arial;
      font-weight: bold;
      font-size: 25px;
      color:blue;
      text-align: center;
      width:45%;
      background-color:lightgreen;
   }

   body {
     font-family: arial;
     font-weight: bold;
     font-size: 20px;
   }

   #button_me {
    background-color: #008CBA;
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
    height: 50px;
    width: 120px
     text-align: center;
    cursor: pointer;
 }

 input[type=text] {
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
   
 }
</style>
      
<script>
function longestWord(string) {
    var str = string.split(" ");
    var longest = 0;
    var word = null;
    str.forEach(function(str) {
        if (longest < str.length) {
            longest = str.length;
            word = str;
        }
    });
    return word.toUpperCase();
}



function test()
{


str_string=document.getElementById("no_input").value;

 document.getElementById("msg").innerHTML = "The longest string in the sentence is "  + 
 longestWord(str_string)+".";
}

</script>

<script>
function clear_me()
{
document.getElementById("msg").innerHTML = "";
document.getElementById("no_input").value = "";
document.getElementById("no_input").focus();
}
</script>

</head>
<body>
<h1 class="art"> Longest String in JavaScript </h1>
    <p  class="art2"> Created By Mr. Jake R. Pomperada, MAED-IT </p>
<br><br>
Enter a sentence: <input id="no_input" type="text" size="50" autofocus>
<br><br>
<p id="msg"> </p> 
<button id="button_me" onclick="test()">Check</button>
&nbsp;&nbsp;&nbsp;
<button id="button_me" onclick="clear_me()">Clear</button>
</br></br>
</body>
</html>





Fibonacci Series in Java

In this article I would like to share with you a sample program that will ask the user to give a number and then our program will generate the corresponding Fibonacci numbers based on the given number by our user using Java as our programming language.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.





Sample Program Output



Program Listing

fibonacci.java

import java.util.Scanner;

// fibonacci.java
// Written By Mr. Jake R. Pomperada, MAED-IT
// February 2, 2018   11:09 AM   Friday
// Bacolod City, Negros Occidental Republic of the Philippines
// jakerpomperada@yahoo.com and jakerpomperada@gmail.com

class fibonacci {
public static void main(String[] args)
      {

      int num1=0, a = 0, b = 0, c = 1;;

        Scanner s = new Scanner(System.in);

        System.out.println();
        System.out.println("=== Fibonacci Series in Java === ");
        System.out.println();

         System.out.print("Give a value of n : ");
         num1 = s.nextInt();
          System.out.println();
         System.out.print("Fibonacci Series : ");
        for(int i = 1; i <= num1; i++)
        {
            a = b;
            b = c;
            c = a + b;
            System.out.print(a+" ");
        }

System.out.println("\n");
System.out.println("\t End of Program");
         System.out.println();
}
}










Prime Number Checker in Java

A simple program that I wrote using Java as my programming language that will ask the user to give a number and then our program will check and determine if the give number is a Prime Number or Not a Prime Number.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.








Sample Program Output


Program Listing

prime_number.java

import java.util.Scanner;

// prime_number.java
// Written By Mr. Jake R. Pomperada, MAED-IT
// February 2, 2018   10:44 AM   Friday
// Bacolod City, Negros Occidental Republic of the Philippines
// jakerpomperada@yahoo.com and jakerpomperada@gmail.com

class prime_number {
public static void main(String[] args)
      {

      int num1=0;
      boolean flag = false;

        Scanner s = new Scanner(System.in);

        System.out.println();
        System.out.println("=== Prime Number Checker in Java === ");
        System.out.println();

         System.out.print("Give a Number : ");
         num1 = s.nextInt();

         for(int i = 2; i <= num1/2; ++i)
         {

             if(num1 %  i == 0)
             {
                 flag = true;
                 break;
             }
         }

         if (!flag) {
System.out.println();
             System.out.println("The given number " + num1 + " is a prime number.");
}
         else {
System.out.println();
                 System.out.println("The given number " + num1 + " is not a prime number.");
}
System.out.println("\n");
System.out.println("\t End of Program");
               System.out.println();
}
}





Longest String in a Sentence in Java


In this article I would like to share with you a sample program that will ask the user to give a string or sentence and then our program will find which of the words in the given string is the longest using Java as our programming language. I am using TextPad as my text editor in writing this program.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.





Sample Program Output


Program Listing

string_long.java

import java.util.*;
import java.util.Scanner;

// string_long.java
// Written By Mr. Jake R. Pomperada, MAED-IT
// February 2, 2018   9:59 AM   Friday
// Bacolod City, Negros Occidental Republic of the Philippines
// jakerpomperada@yahoo.com and jakerpomperada@gmail.com

class string_long {

  public static void main(String[] args) {

     String display;

     Scanner input=new Scanner(System.in);

       System.out.println("\n");
   System.out.print("\t Longest String in a Sentence in Java");
   System.out.println("\n");
   System.out.print("Enter a sentence : ");

      String str_sentence =input.nextLine();

     display = Arrays.stream(str_sentence.split(" ")).max(Comparator.comparingInt(String::length)).orElse(null);
    System.out.println("\n\n");
    System.out.println("The longest string is " + display.toUpperCase() + ".");
    System.out.println("\n");
    System.out.println("\t End of Program");
   System.out.println();
  }
}


Friday, January 26, 2018

Factorial Number Solver in JavaScript

A program that I wrote using JavaScript that will ask the user to give a number and then our program will compute it's factorial equivalent value. The code is very simple and easy to understand.

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.






Sample Program Output


Program Listing

factorial.htm

<!doctype html>
<html>
<head>
<style>

   .art {

      font-family: arial;
      font-weight: bold;
      color:red;
      text-align: center;
      width:55%;
      background-color:yellow;
   }

.art2 {

      font-family: arial;
      font-weight: bold;
      font-size: 25px;
      color:blue;
      text-align: center;
      width:45%;
      background-color:lightgreen;
   }

   body {
     font-family: arial;
     font-weight: bold;
     font-size: 20px;
   }

   #button_me {
    background-color: #008CBA;
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
    height: 50px;
    width: 120px
     text-align: center;
    cursor: pointer;
 }

 input[type=text] {
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
   
 }
</style>
  
    
<script>
function palindrome_number()
{
var i, no, fact;

no=Number(document.getElementById("no_input").value);

fact=1;
for(i=1; i<=no; i++)  
{
fact= fact*i;
}  

 document.getElementById("msg").innerHTML = "The factorial value of  "+ no + " is " +fact + ".";

}
</script>

<script>
function clear_me()
{
document.getElementById("msg").innerHTML = "";
document.getElementById("no_input").value = "";
document.getElementById("no_input").focus();
}
</script>

</head>
<body>
<h1 class="art"> Factorial Number Solver in JavaScript </h1>
    <p  class="art2"> Created By Mr. Jake R. Pomperada, MAED-IT </p>
<br><br>
Give a Number : <input id="no_input" type="text" autofocus required>
<br><br>
<p id="msg"> </p> 
<button id="button_me" onclick="palindrome_number()">Check Number</button>
&nbsp;&nbsp;&nbsp;
<button id="button_me" onclick="clear_me()">Clear</button>
</br></br>
</body>
</html>





Palindrome Number in JavaScript

A very simple program that I wrote in JavaScript that will ask the user to give a number and then our program will check if the given number is a palindrome or not a palindrome.  

I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

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

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.






Sample Program Output


Program Listing

palindrome.htm

<!doctype html>
<html>
<head>
<style>

   .art {

      font-family: arial;
      font-weight: bold;
      color:red;
      text-align: center;
      width:45%;
      background-color:yellow;
   }

.art2 {

      font-family: arial;
      font-weight: bold;
      font-size: 25px;
      color:blue;
      text-align: center;
      width:45%;
      background-color:lightgreen;
   }

   body {
     font-family: arial;
     font-weight: bold;
     font-size: 20px;
   }

   #button_me {
    background-color: #008CBA;
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
    height: 50px;
    width: 120px
     text-align: center;
    cursor: pointer;
 }

 input[type=text] {
    font-family: arial;
    font-weight: bold;
    font-size: 20px;
   
 }
</style>
  
    
<script>
function palindrome_number()
{
var a=0,no=0,b=0,temp=0;


no=Number(document.getElementById("no_input").value);

b=no;
while(no>0)
{
a=no%10;
no=parseInt(no/10);
temp=temp*10+a;
}
if(temp==b)
{
 document.getElementById("msg").innerHTML = "The given number is a  Palindrome.";
}
else
{
document.getElementById("msg").innerHTML="The given number is Not Palindrome.";
}
}
</script>

<script>
function clear_me()
{
document.getElementById("msg").innerHTML = "";
document.getElementById("no_input").value = "";
document.getElementById("no_input").focus();
}
</script>

</head>
<body>
<h1 class="art"> Palindrome Number in JavaScript </h1>
    <p  class="art2"> Created By Mr. Jake R. Pomperada, MAED-IT </p>
<br><br>
Give a Number : <input id="no_input" type="text" autofocus>
<br><br>
<p id="msg"> </p> 
<button id="button_me" onclick="palindrome_number()">Check Number</button>
&nbsp;&nbsp;&nbsp;
<button id="button_me" onclick="clear_me()">Clear</button>
</br></br>
</body>
</html>