Saturday, September 3, 2016

Selection Sort in C++

A program that I wrote a long time ago in my C++ programming class in college to perform selection sort. The code is very simple and easy to use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.



Program Listing

#include <iostream>

using namespace std;

#define MAX 5

void SelSort(int X[],int start,int stop)
{
   int begin=start;
   int smallsofar=begin;
   int tmp;

   if(start<stop)
   {
        for(int i=begin+1;i<=stop;i++)
      {
           if(X[i] < X[smallsofar])
              smallsofar=i;
      }
      tmp=X[begin];
      X[begin]=X[smallsofar];
      X[smallsofar]=tmp;

      SelSort(X,start+1,stop);
   }
}

int main()
{
   int abc[MAX];
    cout << "\t\t\t      SELECTION SORT IN C++";
    cout << "\n\t\t Created By: Mr. Jake R. Pomperada, MAED-IT";
    cout << "\n\n";   
   for(int i=0;i<5;i++) {

    cout << "Enter Item No.:" << i+1 << ":";
    cin >> abc[i];
   }
   cout << "\n\t Original Arrangement of Numbers";
   cout << "\n\n";
   for(int i=0;i<5;i++)
        {

        cout << "\t " << abc[i] << " ";
           }

   SelSort(abc,0,MAX-1);
   cout << "\n";
   cout << "\n\t Sorted Arragmenent  of Number";
   cout << "\n\n";
   for(int i=0;i<5;i++)
        {
        cout << "\t " << abc[i] << " ";
           }
cout << "\n\n";
system("PAUSE");
}

Odd and Even Numbers Using Structure in C++

A simple program to check if the given number is an odd or even number using structure in C++.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.



Program Listing


#include <iostream>
#include <iomanip>

using namespace std;



struct odd {

int n;

  int odd_even() {

  if (n % 2 == 0)
        {
                 cout << n <<" Number is even!\n";
        }
        else
        {
                 cout << n << " Number is odd!\n";
        }
   return(n);

  }

};

main() {

    odd value;

   cout << "\t\t ODD and Even Number Determiner";
   cout << "\n\n";
   cout << "Enter a Number :";
   cin >> value.n;
   cout << "\n\n";
   cout << value.odd_even();
   cout << "\n\n";
   system("pause");


}


Loan Interest Solver in Perl

A simple program that I wrote using PERL to solve the loan of the customer. I will ask the user for the principal amount load, interest rate and the time.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

sub find_interest {
  ($amount,$rate,$time) = @_;
   $solve_interest = ($amount * $rate * $time) / 100;
}

print "\n\n";
print "Loan Interest Solver";
print "\n\n";
print "Enter Principal Amount : ";
chomp($amount=<>);
print "Enter Rate of Interest : ";
chomp($rate=<>);
print "Enter Period of Time   : ";
chomp($time=<>);
print "\n\n";
print "Display Result";
print "\n\n";
print "The interest rate is $" ;
print  find_interest($amount,$rate,$time);
print "\n\n";
print "End of Program";
print "\n\n";


Cube Root in C++

A simple program that I wrote in C++ to show how to solve cube root. I am using CodeBlocks as my text editor and Dev C++ as my C++ compiler.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#include <iostream>
#include <iomanip>

using namespace std;

struct cube{

  int value;

  int solve()
    {
        return(value * value * value);
    }
  };

  main() {

       cube val;

      cout << "\t\t Cube Root Solver 1.0";
      cout << "\n\n";
      cout << "Enter a Number : ";
      cin >> val.value;
      cout << "\n";
      cout << "The Cube Root Value of " << val.value
           << " is " << val.solve() << ".";
     cout << "\n\n";
     system("pause");
  }


Power of a Number Perl

A simple program that will ask the user to give the base and power of a number from the user using PERL as our programming language.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.


Program Listing

#!D:\xampp\perl\bin

sub solve_power {
    ($base1, $exponent) = @_;
    $solve  = $base1 ** $exponent;
}

print "\n\n";
print "Power of a Number";
print "\n\n";
print "Enter base number : ";
chomp($base=<>);
print "Enter power number (positive integer) : ";
chomp($exp=<>);
print "\n\n";
print "Display Result";
print "\n\n";
print "$base ^ $exp  = " ;
print  solve_power($base,$exp);
print "\n\n";
print "End of Program";
print "\n\n";

Leap Year Checker in Delphi

A program that I wrote using Delphi programming language that will ask the user to give a year and then our program will check if the given year by the user is a leap year or not a leap year. The code is very simple because I am using a function in Delphi called IsLeapYear() to check if the given year is a leap year or not. 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 mobile number here in the Philippines is 09173084360
.





Sample Program Output


Program Listing

leap.pas

unit leap;

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 Given_Year : Integer;

procedure TForm1.Button1Click(Sender: TObject);
begin

Given_Year := StrToInt(Edit1.Text);

If IsLeapYear(Given_Year) Then
    Label3.Caption := 'The year ' + Edit1.Text + ' is a Leap Year.'
Else
   Label3.Caption :=  'The year ' + Edit1.Text + ' is not a Leap Year.'
end;

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

end.



Linear Search in PHP

A simple program that I wrote that will perform sequential or linear searching from a list of names in an array in PHP. The code is very short and easy to understand.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.



Program Listing


<html>
<body>
<center>
<h1>Linear Search in PHP</h1>
<?php
$people = array("Peter", "Joe", "Pedro", "Maria","Ana","Luisa");
if (isset($_POST['find']))
{
    $val=$_POST['search_me'];
    if (in_array($val, $people))
      {
          echo "Match found from the list.";
      }
    else
      {
          echo "Match not found in the list.";
      }
}
?>
<form method="post" action="linear.php">
    Enter a Name to be search <input type="text" name="search_me">
    <input type="submit" value="Search" name="find">
</form>
</center>
</body>
</html>

Range of Fibonacci Numbers in PHP

A simple program that I wrote using PHP that will ask the user to give a range from lower bound to upper bound and then our program will generate a series of fibonacci number based on the range that is being specify by our user.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.



Sample Program Output


Program Listing

<html>
<head>
<title>
Range of Fibonacci Numbers
</title>
  </head>
<style>
body {
font-family:arial;
font-size  :20px;
background-color:lightgreen;
    }
    input[type=submit]
{
    font-size: 20px; 
    font-weight: bold;
    font-family: arial; 
    background-color: lightblue;
}
</style>
<body>
 <?php
 error_reporting(0);
 $a=$_POST['lower'];
 $b=$_POST['upper'];
 if(isset($_POST['clear']))
{
$a="";
$b="";
$fib3="";
}
 ?>
<BR>
   <h3>Range in Fibonacci Numbers</h3>
<form method="post" action="index.php" name="prime_me">
    Lower Bound &nbsp;&nbsp;<input type="text" name="lower" 
     size="5" value="<?php echo $a; ?>" autofocus>
    &nbsp;&nbsp;&nbsp;&nbsp;    
    Upper Upper Bound &nbsp;&nbsp;<input type="text" name="upper" 
     size="5"  value="<?php echo $b; ?>">
   <br><br>
    <input type="submit" name="check" value="Ok">
    &nbsp;&nbsp;&nbsp;&nbsp;  
    <input type="submit" name="clear" value="Clear">
</form>
<h3> DISPLAY RESULTS </h3>
<?php
if(isset($_POST['check']))
{
    $fib1=0;
    $fib2=1;
    $fib3=0;
    
    $a=$_POST['lower'];
    $b=$_POST['upper'];
        
for($i=$a;$i<$b;$i++)
      {
        if ($fib3<=$b)
            {
                if ($fib3>=$a)
                    {
                        echo " " .$fib3." ";
                    }
                $fib1=$fib2;
                $fib2=$fib3;
                $fib3=$fib1+$fib2;
            }
      }
}
?>
</body>
</html>




Range of Prime Numbers in PHP

Here is a simple program that I wrote in PHP as my programming language that will ask the user to give the range from lower bound and upper bound and generate the corresponding prime number from the given range. The code is very easy to undertand and use.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.




Sample Program Output


Program Listing

<html>
<head>
<title>
Range of Prime Numbers in PHP
</title>
  </head>
<style>
body {
font-family:arial;
font-size  :20px;
background-color:lightgreen;
    }
    input[type=submit]
{
    font-size: 20px; 
    font-weight: bold;
    font-family: arial; 
    background-color: lightblue;
}
</style>
<body>
 <?php
 error_reporting(0);
 $a=$_POST['lower'];
 $b=$_POST['upper'];
 if(isset($_POST['clear']))
{
$a="";
$b="";
}
 ?>
<BR>
   <h3>Range in Prime Numbers</h3>
<form method="post" action="prime.php" name="prime_me">
    Lower Bound &nbsp;&nbsp;<input type="text" name="lower" 
     size="5" value="<?php echo $a; ?>" autofocus>
    &nbsp;&nbsp;&nbsp;&nbsp;    
    Upper Upper Bound &nbsp;&nbsp;<input type="text" name="upper" 
     size="5"  value="<?php echo $b; ?>">
   <br><br>
    <input type="submit" name="check" value="Ok">
    &nbsp;&nbsp;&nbsp;&nbsp;  
    <input type="submit" name="clear" value="Clear">
</form>
<h3> DISPLAY RESULTS </h3>
<?php
if(isset($_POST['check']))
{
    $a=$_POST['lower'];
    $b=$_POST['upper'];
    $flag=0;
    for($a;$a<$b;$a++)
    {
        for($j=2;$j<$a;$j++)
        {
            if($a%$j==0)
            {
                $flag=1;
            }
        }
        if($flag==0)
            {
               echo " ".$a." ";
            }
        $flag=0;
    }
}
?>
</body>
</html>



Odd and Even Number Checker in Delphi

A very 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 by our user is an odd or even number.

I am using Borland Delphi 7 as my Delphi compiler in this program. I hope you will like my work. Thank you very much.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.




Sample Program Output


Program Listing

even.pas

unit even;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.dfm}

Var Number, Check : Integer;


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

Check  := (Number MOD 2);

If (Check = 0) Then
  Label5.Caption := 'The given number ' + Edit1.Text + ' is a an EVEN number.'
Else
  Label5.Caption := 'The given number ' + Edit1.Text + ' is a an ODD number.'
end;

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

end.





Friday, September 2, 2016

Area of the Circle Solver in Delphi

A program that I wrote using Delphi that will ask the user to give the radius of the circle and then our program will compute for it's area. The code is very easy to understand and use. I intended my work for those that are beginners in Delphi programming.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

area.pas

unit area;

interface

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

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



    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const

Pi = 3.1416;

Var
  Radius : Integer;
  Area_Circle   : Real;

  procedure TForm1.Button1Click(Sender: TObject);
begin
Radius := strtoint(Edit1.text);
Area_Circle   :=  (Pi * Radius * Radius);
Label4.Caption := 'The area of the circle is ' + FormatFloat('0.00',Area_Circle);
end;

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

end.