Wednesday, October 5, 2016

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>

Greet Me in Jquery

A simple script that I wrote using JQuery that will ask the user's name and then our program will say Hello How are you to the user. It shows how to accept input values such as string and display 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

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("form").submit(function(){
        var names=  document.getElementById("fname").value;
        alert("Hello " + names + "How are you?");
    });
});
</script>
</head>
<body>

<form action="">
What is your name <input type="text" id="fname" name="FirstName" value=""><br>

  <input type="submit" value="Submit">
</form>

</body>
</html>

Saturday, October 1, 2016

Positive and Negative Number Checker in Delphi

A simple program that I wrote using Delphi as my programming language that will ask the user to give a number and then our program will check and determine whether the given number from the user is a positive or negative number. The code is very short and very 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

positive_negative_numbers.pas

unit positive_negative_numbers;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label3: TLabel;
    Label4: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

var number_value : integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
     number_value := StrToInt(Edit1.Text);

     if (number_value >=0) then
      Begin
         label2.Caption :=  'The Give Number ' + IntToStr(number_value)
                 + ' is a Positive Number.';
      end
      else
         Begin
             label2.Caption :=  'The Give Number ' + IntToStr(number_value)
                 + ' is a Negative Number.';
         end;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.text     :='';
label2.caption := '';
edit1.setfocus;
end;

end.









Addition of Three Numbers in Visual Basic





This is my second video tutorial for Youtube

Positive and Negative Number Checker in Visual Basic

A simple program that I wrote using Microsoft Visual Basic 5 to check if the given integer number by our user is a positive or negative number. The program 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

Private Sub Command1_Click()

number_value = Val(Text1.Text)

If (number_value >= 0) Then
  Label4.Caption = "The given number " & number_value & " is a Positive Number."
Else
    Label4.Caption = "The given number " & number_value & " is a Negative Number."
End If
  
End Sub

Private Sub Command2_Click()
Text1.Text = ""
Label4.Caption = " "
End Sub





Addition of Two Numbers in C++