Friday, October 7, 2016

Absolute Value Solver in Delphi

A simple program that I wrote using Borland International Delphi 7 to solve the absolute value of the given negative integer number by the user. The 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

unit abs;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

Var value_a,solve_a : integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
     value_a := StrToInt(Edit1.Text);
     solve_a := (-value_a);
     Label3.Caption := 'The absolute value of ' + edit1.text
                  + ' is ' + inttostr(solve_a) + '.';

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text      :='';
Label3.Caption  :='';
Edit1.SetFocus;
end;

end.


Absolute Value Solver in C#

A simple program that I wrote using Microsoft Visual C#.NET to solve the absolute value of the given negative integer number by the user. The 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

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int abs_value = 0, solve_abs=0;

            if (!int.TryParse(textBox1.Text, out abs_value))
            {
                MessageBox.Show("I need just a number in the textbox.");
                textBox1.Text = "";
                textBox1.Focus();
            }
            
            else
            {
                abs_value = Convert.ToInt32(textBox1.Text);
                solve_abs = Math.Abs(abs_value); label3.Text = "The absolute value of " 
                    + abs_value +" is " + solve_abs + ".";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = "";
            label3.Text = " ";
            textBox1.Focus();
        }
    }
}






Absolute Value Solver in Visual Basic.NET

A simple program that I wrote using Microsoft Visual Basic.NET to solve the absolute value of the given negative integer number by the user. The 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

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim value_a As Integer
        Dim solve_a As Integer

        value_a = Val(TextBox1.Text)

        solve_a = Math.Abs(value_a)

        Label3.Text = "The absolute value of " & value_a & " is " & solve_a & "."

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TextBox1.Text = ""
        Label3.Text = ""
        TextBox1.Focus()
    End Sub
End Class




Absolute Value Solver in Visual Basic

A simple program that I wrote using Microsoft Visual Basic 5 to solve the absolute value of the given negative integer number by the user. The 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()
Dim value_a As Integer

value_a = Abs(Val(Text1.Text))

Label3.Caption = "The absolute value of " & Text1.Text & _
                 " is " & value_a & "."
End Sub


Private Sub Command2_Click()
Text1.Text = ""
Text1.SetFocus
End Sub



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;

    }

}