Friday, October 7, 2016

Absolute Values Solver in JavaScript

Here is another simple program that I wrote in JavaScript that will ask the user to give a negative integer number and then our program will solve its is absolute value equivalent of the negative number. The code is very short and easy to understand among beginners in JavaScript programming.

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

<!DOCTYPE html>
<html>
<head>
    <title>Absolute Value Solver in JavaScript</title>
    <style type="text/css">
    .formLayout
    {
        font-family:arial;
size:14px;
background-color: #f3f3f3;
        border: solid 1px #a1a1a1;
        padding: 35px;
        width: 300px;
    }
    
    .formLayout label, .formLayout input 
    {
        display: block;
        width: 120px;
        float: left;
        margin-bottom: 20px;
    }
 
    .formLayout label
    {
        text-align: right;
        padding-right: 20px;
    }
 
 .formLayout label
    {
        text-align: right;
        padding-right: 20px;
    }
    br
    {
        clear: left;
    }
    </style>
</head>
<body>
<script language="JavaScript">
function Find_Absolute_Value(){
var inputNum=document.form_abs.number_value.value;
var result = Math.abs(inputNum);
document.form_abs.answer.value = result;
}
</script>
<div class="formLayout">
<form name=form_abs>
<h4> Absolute Value Solver in JavaScript</h4>
<label>Give a Number </label>
<input type="text" name="number_value" size=5>
<label>The Answer is </label>
<input type="text" name="answer" size=5><br>

<input type="button" value="Solve" onClick='Find_Absolute_Value()'>
</form>
</div>
</body>
</html>

Wednesday, October 5, 2016

Odd and Even Number Using Method in Java

A program that I wrote using Java that uses method to check if the given number is an odd or even. 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.


Program Listing

// Problem : Write a program in Java that will check if the given number by the user is an
//           Odd or Even Number.         
// Date:  June 28, 2015
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Email Address: jakerpomperada@yahoo.com and jakerpomperada@gmail.com

import java.util.Scanner;


class odd_even_checker {
    public int check_odd_even_number(int value)
    {
      if((value % 2) == 0) 
System.out.println("The given number is " + value + " is Even Number.");
else
System.out.println("The given number is " + value +  " is Odd Number.");
    return 0;
    }

 
public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of an object
  
  odd_even_checker num = new odd_even_checker();
      
  System.out.println();
  System.out.println("===== ODD OR EVEN NUMBER CHECKER =====");
  System.out.println();
  System.out.print("Enter a Number :  ");
  int number_given =   scan.nextInt();
  
  System.out.println();
     num.check_odd_even_number(number_given);
  System.out.println("\n\n");
  System.out.print("Do you Want To Continue (Y/N) :=> ");
   a=scan.next().charAt(0);

   } while(a=='Y'|| a=='y');
          System.out.println("\n");
          System.out.println("\t ===== END OF PROGRAM ======");
         System.out.println("\n");
 }
  
   } // End of Program




















Count Capital and Small Letters in JQuery

A simple program that I wrote that will ask the user to give a string or a word and then our program will count how many capital and small letters found in the word,string or sentence using JQuery as our JavaScript library.


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.



Program Listing

<html>
  <head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <title>Count Capital and Small Letters in JQuery</title>
         <style>
        body{
font-family:arial;
font-size:15px;
font-weight:bold;
}  
</style>
        <script>
  $(function(){
$("#count").click(function(){
if (document.getElementById("str").value == '') {
alert("Textbox is Empty !!! Please provide some string.");
document.getElementById("str").value = "";
document.getElementById("upper_str").value = "";
document.getElementById("lower_str").value = "";
document.getElementById("str").focus();
                        }
else {
var str1 = document.getElementById("str").value;
   var numUpper = str1.length - str1.replace(/[A-Z]/g, '').length;  
var numLower = str1.length - str1.replace(/[a-z]/g, '').length;  
                        var result = document.getElementById("upper_str");
var result2 = document.getElementById("lower_str");
                        result.value = numUpper;
result2.value = numLower;
}
       });
});
                   
            $(function(){    
$("#clear").click(function(){
document.getElementById("str").value = "";
   document.getElementById("upper_str").value = "";
   document.getElementById("lower_str").value = "";
   document.getElementById("str").focus();
});
});
        </script>
  </head>
  <body>
      <br><br>
      <h3>Count Capital and Small Letters in JQuery</h3>
  <br>
        Enter a String <input type="text" id="str" name="str" value="" size="30" autofocus/>
        <br><br>
        <input type="button" name="Submit"  id="count" value="Count" title="Click here to count the capital and small letters."/>
&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="Submit" id="clear" value="Clear" title="Click here to clear the text box."/>
<br><br><br><br>
        Number of Capital Letter(s) is  <input type="text" id="upper_str" name="upper_str" size="3"/>
<br><br>
Number of Small Letter(s) is  <input type="text" id="lower_str" name="lower_str" size="3"/>
  </body>
</html>


Input and Output in Array in PERL

Here is a very short program that I wrote using PERL that will ask the user to give a series of  number store the given number by the user in array and display on the screen.

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.


Program Listing

#!D:\xampp\perl\bin

my @arr;
my $count =5;

$a=1;
print "\n\n";
print "\t\t Input and Output of Array in PERL";
print "\n\n";
 for ($a..5) {
    print "Enter value in item no. $a : ";
    my $num = <STDIN>;
    chomp $num;
    push @arr, $num;
    $a+=1;
}


print "\n\n";
print "The List of Values";
print "\n\n";
foreach (@arr) {
  printf "\t %s\n", $_;
}
print "\n";
print "End of Program";
print "\n";

Highest and Lowest Number in PERL

Here is a sample program that will ask the give to give a series of integer number and then our program will check which of the given number by the user is the highest and lowest using PERL as my 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.


Program Listing

#!D:\xampp\perl\bin

my @arr;
my $count =10;
my ($lowest, $highest);

$a=1;
print "\n\n";
print "\t\t Highest and Lowest Number in PERL";
print "\n\n";
 for ($a..10) {
    print "Enter value in item no. $a : ";
    my $num = <STDIN>;
    chomp $num;
    push @arr, $num;
    $a+=1;
}


for (@arr) {
    $lowest  = $_ if !$lowest || $_ < $lowest;
    $highest = $_ if !$highest || $_ > $highest;
};


print "\n\n";
print "Display Result";
print "\n\n";
#foreach (@arr) {
#  printf "%s\n", $_;
#}
print "The highest number is  $highest.\n";
print "\n";
print "The lowest number is $lowest.";


New Bacolod Enterprises Payroll System in Java

Here is a simple payroll system that I wrote in my Java programming class before that will manage the payroll of the employees in the company.

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.


Program Listing

import java.io.*;
import java.text.*;

public class system{
    static BufferedReader in =  new BufferedReader(new InputStreamReader(System.in));

    public static void main(String [] args) throws IOException {

        String EmpCode = “”;

        while(!EmpCode.equals(“0?)) {

            System.out.print(“Enter Employee Code: “);
            EmpCode = in.readLine();

            String EmpInfo[] = getInfo(EmpCode);

            double basicsalary =  Double.parseDouble(EmpInfo[3]);

           
            System.out.println(” NEW BACOLOD ENTERPRISES PAYROLL SYSTEM“);
            System.out.println(”\n\n“);

            System.out.println(“READ ME FIRST : ****************************”);
            System.out.println(” * Input for Regular Hours  — > 8:00 – 17:00 “);
            System.out.println(” * Input for OT Hours — > 17:30 – 20:30 “);
            System.out.println(” * OT Income = ( Basic Salary / 8 ) * 1.1 “);
            System.out.println(” * Holiday = ( Basic Salary / 8 ) * 1.1 “);
            System.out.println(“*******************************************”);
            System.out.println(“============= Employee Information ==========”);
            System.out.println(“Employee Code: ” + EmpInfo[0]);
            System.out.println(“Employee Name: ” + EmpInfo[1]);
            System.out.println(“Employee Position: ” + EmpInfo[2]);
            System.out.println(“Employee  Basic Salary: ” + EmpInfo[3]);
            System.out.println(“=======================================”);

            String days[] = {“Monday”,”Tuesday”,”Wednesday”,”Thursday”,”Friday”};

            double timeInOut[][] =  new double[2][5];
            double otInOut[][] =  new double[2][5];

            String strTemp = “”;
            String tmpTime[] = new String[2];

            double tmpHours, totalHours = 0, tmpRegIncome = 0, totalRegIncome = 0,
            tmpOTHours,totalOTHours = 0, tmpOTIncome, totalOTIncome = 0;

            for(int i = 0; i < 5; i++){

                System.out.print(“Time In for ” + days[i] + “: “);
                strTemp = in.readLine();
                tmpTime = strTemp.split(“:”);
                timeInOut[0][i] = Double.parseDouble(tmpTime[0]) + (Double.parseDouble(tmpTime[1]) / 60);

                System.out.print(“Time Out for ” + days[i] + “: “);
                strTemp = in.readLine();
                tmpTime = strTemp.split(“:”);
                timeInOut[1][i] = Double.parseDouble(tmpTime[0]) + (Double.parseDouble(tmpTime[1]) / 60);

                System.out.print(“is ” + days[i] + ” Holiday?: “);
                String isHoliday =  in.readLine();

                System.out.print(“OT Time In for ” + days[i] + “: “);
                strTemp =  in.readLine();
                tmpTime = strTemp.split(“:”);
                otInOut[0][i] = Double.parseDouble(tmpTime[0]) + (Double.parseDouble(tmpTime[1]) / 60);

                System.out.print(“OT Time Out for ” + days[i] + “: “);
                strTemp = in.readLine();
                tmpTime = strTemp.split(“:”);
                otInOut[1][i] = Double.parseDouble(tmpTime[0]) + (Double.parseDouble(tmpTime[1]) / 60);

                if(timeInOut[0][i] < 8)timeInOut[0][i] = 8;
                if(timeInOut[1][i] > 17)timeInOut[1][i] = 17;
                if(otInOut[0][i] < 17.5 && otInOut[0][i] != 0)otInOut[0][i] = 17.5;
                if(otInOut[1][i] > 20.5)otInOut[1][i] = 20.5;

                tmpHours = timeInOut[1][i] – timeInOut[0][i];
                tmpOTHours = otInOut[1][i] – otInOut[0][i];

                if(tmpHours > 4)tmpHours–;

                if(isHoliday.equals(“Yes”)){
                    totalOTHours += tmpHours;
                    totalOTIncome += tmpHours * ((basicsalary / 8) * 1.1);
                    totalHours += tmpHours;
                    tmpRegIncome = tmpHours * (basicsalary / 8);
                }else{
                    totalHours += tmpHours;
                    tmpRegIncome = tmpHours * (basicsalary / 8);
                }

                    totalOTHours += tmpOTHours;
                    totalOTIncome += tmpOTHours * ((basicsalary / 8) * 1.1);
                    totalRegIncome += tmpRegIncome;

            }
                    double grossincome =  totalRegIncome + totalOTIncome;

                    DecimalFormat df = new DecimalFormat(“#.##”);

                    System.out.println(“=========== Total Output ==============”);
                    System.out.println(“Total work hours: ” + df.format(totalHours));
                    System.out.println(“Total regular income: ” + df.format(totalRegIncome));
                    System.out.println(“Total OT hours: ” + df.format(totalOTHours));
                    System.out.println(“Total OT Income: ” + df.format(totalOTIncome));
                    System.out.println(“Gross Income: ” + df.format(grossincome));
                    System.out.println(“=====================================”);

        }

    }

    static String[] getInfo(String EmpCode){

        String getInfo[] = new String [4];
        String strLine;
        int ctr =0;
        boolean isFound = false;

        try{

            FileInputStream fstream =  new FileInputStream(“payroll.txt”);
            DataInputStream dstream  =  new DataInputStream(fstream);
            BufferedReader br = new BufferedReader(new InputStreamReader(dstream));

            while((strLine = br.readLine()) != null && ctr < 4){
                if(strLine.equals(EmpCode))isFound = true;
                if(isFound){
                    getInfo[ctr] =  strLine;
                    ctr++;

                }

            }

            br.close();

        }catch(IOException e){

            System.out.println(“Error: ” + e.getMessage());
        }

        return getInfo;

    }

}

Remove Consonants in JavaScript

A very simple script that I wrote in JavaScript that will ask the user to give a word or a sentence then our program will remove the consonants in the given word or sentence.

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.



Program Listing

<!DOCTYPE html>
<html>
<head>
    <title>Remove Consonants</title>
    <style type="text/css">
    .formLayout
    {
        font-family:arial;
    size:14px;
    background-color: lightgreen;
        border: solid 2px #a1a1a1;
        padding: 30px;
        width: 250px;
    }

    .formLayout label, .formLayout input

    {
        display: block;
        width: 250px;
        float: left;
        margin-bottom: 20px;
    }


 .formLayout label
    {
        text-align: left;

    }
    br
    {
        clear: left;
    }
    </style>
</head>
<body>
<script language="JavaScript">
function execute_program(){
var inputStr=document.form_vowel.strings_remove.value;
var result = Remove_Consonants_Str(inputStr);
document.form_vowel.answer.value = result;
}
 
function Remove_Consonants_Str(str) {
  return str.replace(/[BCDFGHJKLMNPQRSTVWXYZbcdfghjklmnpqrstvwxyz]/gi, '');
}

</script>
<div class="formLayout">
<form name=form_vowel>
<h4>Remove Consonants </h4>
<label>Enter a Word or String </label>
<input type="text" name="strings_remove" size=15>
<label>The Result  </label>
<input type="text" name="answer"  readonly="readonly" size=15><br>
<input type="button" value="Remove" onClick='execute_program()'>
</form>
</div>
</body>
</html>


Remove Vowels in JavaScript

A very simple script that I wrote in JavaScript that will ask the user to give a word or a sentence then our program will remove the vowels in the given word or sentence.

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.



Program Listing

<!DOCTYPE html>
<html>
<head>
    <title>Remove Vowels</title>
    <style type="text/css">
    .formLayout
    {
        font-family:arial;
    size:14px;
    background-color: lightgreen;
        border: solid 2px #a1a1a1;
        padding: 30px;
        width: 250px;
    }

    .formLayout label, .formLayout input

    {
        display: block;
        width: 250px;
        float: left;
        margin-bottom: 20px;
    }


 .formLayout label
    {
        text-align: left;

    }
    br
    {
        clear: left;
    }
    </style>
</head>
<body>
<script language="JavaScript">
function execute_program(){
var inputStr=document.form_vowel.strings_remove.value;
var result = Remove_Vowels_Str(inputStr);
document.form_vowel.answer.value = result;
}

function Remove_Vowels_Str(str) {
  return str.replace(/[aeiouAEIOU]/gi, '');
}

</script>
<div class="formLayout">
<form name=form_vowel>
<h4>Remove Vowels </h4>
<label>Enter a Word or String </label>
<input type="text" name="strings_remove" size=15>
<label>The Result  </label>
<input type="text" name="answer"  readonly="readonly" size=15><br>
<input type="button" value="Remove" onClick='execute_program()'>
</form>
</div>
</body>
</html>

Positive and Negative Number Checker in JQuery

Here is a very simple program that I wrote using JQuery that will ask the user to give a number and then our program will check and determine whether the given number is a positive number or negative number using JQuery as our JavaScript library.

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.


Program Listing


<html>
<head>
<title> Positive or Negative Number Checker in JQuery </title>
<script src="jquery.js"></script>
<style>
body {
 font-family: arial;
 font-size:15px;
 font-weight:bold;
 }

 .input_bold {
    font-weight: bold;
font-size:15px;
color: red;
}
</style> 
<script>
$(document).ready(function(){

 $("#check_it").click(function(){
  var num = $("#num_value").val();

  if(jQuery.isNumeric(num) == false){
        alert('Please enter numeric value');
$('#num_value').val('');
$("#results").val('');
        $('#num_value').focus();
     }
  else if (num>= 0)
{
remarks = num+ " is a Positive Number.";
$("#results").val(remarks);
}
  else {
remarks = num+ " is a Negative Number.";
$("#results").val(remarks);
      }
 });

   $("#clear").click(function(){

   $("#num_value").val('');
   $("#results").val('');
   $("#num_value").focus();
    
  });
  
  
 });


 </script>
</head>
<body>
<form>
Give a Number
<input type="text" id="num_value" size="3"autofocus/><br><br>

The result
<input type="text" id="results" class="input_bold" size="30" readonly/><br>
<br><br>
<button type= "button" id ="check_it">Check </button>    
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<button type= "button" id ="clear">Clear </button>    
</form>
</body>
</html>