Thursday, June 25, 2015

Addition of Three Numbers in Turbo Pascal

In this article I would like to share with you the first programming language that I have learned in college where I understand what is programming is all about. I'm using Pascal in my simple program Addition of Three Numbers using Turbo Pascal.  Pascal is one of the most programmer friendly programming language it a sense it uses common English statement and it is not case sensitive compared with C,C++ and Java.

However in today's standard Pascal is no longer being used in development primary reason majority of our software that is being developed is written in C,C++,C# or Java and other programming languages that has similar to C or C++.

What does our program will do is to ask the user to enter three numbers and then our program will compute and find the some of the three numbers given by our user.

I hope you will find my work  useful in a sense the logic of programming is also applied in this simple program.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.




Sample Program Output

Program Listing

Program Addition_of_Three_Numbers;
Uses Crt;

Var a,b,c,sum : integer;

Begin
  Clrscr;
  a:=0;b:=0;c:=0;sum:=0;
  writeln('Addition of Three Numbers');
  writeln;
  write('Enter three numbers :=> ');
  readln(a,b,c);
  writeln;
  sum := (a+b+c);
  writeln('The sum of ',a,'',b,' and ', c , 'is ' ,sum,'.');
  readln;
End.


Sunday, June 21, 2015

Persons Profile System in JSP and XML

A simple persons profle system that I wrote in JSP and XML that will retrieve the name and age of the person that is being stored in XML file. The code is very short and easy to understand perfect for beginners in Java Servers Pages or JSP programming.

In this program I am using Java EE IDE provided freely by Eclipse.org and Apache Tomcat as my application server. I hope you will find my work useful in learning web programming using Java Server Pages or JSP.

If you have some questions please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output


Program Listing


persons.jsp

<%@page import="org.w3c.dom.*, javax.xml.parsers.*" %>
<%
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.parse("http://localhost:8080/helloworld/person.xml");
%>
<%!
public boolean isTextNode(Node n){
return n.getNodeName().equals("#text");
}
%>

<html>
<title> Persons Profile System in JSP and XML </title>
<head>
    
</head>
<style>
label {
      display: block;
  float: left;
  width : 250px;    
font-size:20px;
}
input, select {
                width: 200px;
                border: 2px solid #000;
                padding: 0;
                margin: 0;
                height: 30px;
                -moz-box-sizing: border-box;
                -webkit-box-sizing: border-box;
                box-sizing: border-box;
            }
            input {
                text-indent: 4px;
            }
</style>

<!--  Code for translating thai language in the web browser -->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 
  <body bgcolor="lightgreen">
  <div class="container">
 <h3>Persons Profile System in JSP and XML </h3>
</div>
<br><br>
<form method="post" action="persons.jsp">
<label> Select  </label>
<select id="select" class="select" name="filter" style="text-align:center;">
<option value="1"  ${param.filter == '1' ? 'selected' : ''}> 1st Choice</option>
<option value="2"  ${param.filter == '2' ? 'selected' : ''}> 2nd Choice</option>
</select> <br><br>
<input type="submit" id="submit" name="submit" value="OK" title="Click here to select your choice.">
</form> <br>
     

   <%
   
   
   String option = request.getParameter("filter");  
      
    
   if("1".equals(option)){
 
%>  



 <table border='2'>
 <tr>
  <th>NAME</th>
  <th>AGE</th>
  </tr>  
 <%   Element  element = doc.getDocumentElement(); 
NodeList personNodes = element.getChildNodes();     
for (int i=0; i<personNodes.getLength(); i++){
Node emp = personNodes.item(i);
if (isTextNode(emp))
continue;
NodeList NameDOBCity = emp.getChildNodes(); 
%>
<tr>
     <%
for (int j=0; j<NameDOBCity.getLength(); j++ ){
Node node = NameDOBCity.item(j);
if ( isTextNode(node)) 
continue;
%>
<td>     <%= node.getFirstChild().getNodeValue() %></td>
<%
%>
</tr>
<%
}
%>
</table>
<% } %>
</body>   
 
</html>



person.xml


<people>
  <person>
    <name>Joe Tan </name>
    <age>30</age>
  </person>
  <person>
    <name>Ana Maria Chua</name>
    <age>29</age>
  </person>
  <person>
    <name>Ferdinand Lim</name>
    <age>45</age>
  </person>
  <person>
    <name>Raul Smith</name>
    <age>61</age>
  </person>
<person>
    <name>Leslie Paul Adams</name>
    <age>53</age>
  </person>
<person>
    <name>John Ching</name>
    <age>78</age>
  </person>

</people>

Math Operations in JSP

In this short article I would like to share with you a program that I wrote in Java Server Pages or JSP I called this program Math Operations in JSP. What program does is to ask the user to enter two numbers and then it will find the sum, product, difference and quotient of two numbers. JSP is the scripting language used in J2EE programming in Java it is similar to PHP, Ruby or Perl but it uses more Java programming language statements. 

In this program I am using Java EE IDE provided freely by Eclipse.org and Apache Tomcat as my application server. I hope you will find my work useful in learning web programming using Java Server Pages or JSP.

If you have some questions please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.



Sample Program Output


Program Listing

<HTML>
    <HEAD>
        <TITLE>Math Operations in JSP</TITLE>
    </HEAD>

    <BODY BGCOLOR="lightgreen">
        <H1>Basic Math Operations in JSP</H1>
             <FORM NAME="form1" METHOD="POST">
       Enter first value  : <input type="text" name="value1" size="10" ><br>
       Enter second value : <input type="text" name="value2" size="10"><br>
           
           <br><br>
            <INPUT TYPE="SUBMIT" NAME="submit" VALUE="Solve">
        </FORM>
<%
int x=  Integer.parseInt(request.getParameter("value1"));
int y = Integer.parseInt(request.getParameter("value2"));
   
  int sum = (x+y);
  int difference = (x-y);
  int product = (x*y);
  int quotient = (x/y);
%>
         <% 
            if(request.getParameter("submit") != null) {
            out.print("The sum of " + x + " and " + y + "  is  " + sum + ". <br>");   
            out.print("The difference of " + x + " and " + y + "  is  " + difference + ". <br>"); 
            out.print("The product of " + x + " and " + y + "  is  " + product + ". <br>");   
            out.print("The quotient of " + x + " and " + y + "  is  " + quotient + ". <br>");  
        %>
        
        <%
            }
        %>
        
    </BODY>
</HTML>



Thursday, June 18, 2015

Greeter Program in Java Server Pages or JSP

In this article I would like to share with you a simple greeter program that I wrote using Java Server Pagers or JSP scripting language that is based in Java programming language. What does the program will do is very simple it will ask the user its first and last name and then say hello to the user.

I just wrote this code as a learning aid in my study of JSP in J2EE programming for web in Java. I hope beginners like me will benefited from my work.

If you have some questions please send me an email at jakerpomperada@gmail.comand jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.


Program Listing

<html>
<head>
<title>Greeter in JSP</title>
</head>
<body>
<form action="test.jsp">
<table border="1">
<tr>
<td>Enter First Name</td>
<td><input type="text" name="first_name" id="first_name" value=""></td>
<td>Enter Last Name</td>
<td><input type="text" name="last_name" id="last_name" value=""></td>
<td><input type="Submit" value="Click to Submit"></td>
</tr>
</table>
</form>
<br>
<%
String first_name = request.getParameter("first_name");
String last_name = request.getParameter("last_name");
if (first_name == null ||  last_name == null) {

} else { 
if (first_name.length() == 0 || last_name.length() ==0) {
%>
<b>myText is empty</b>
<% } else { %>
<b>Hello <%= first_name %> <%= last_name %></b>
<%
}
}
%>
</body>
</html> 

Sunday, June 7, 2015

Cars Collections Information System in PHP and XML

A simple application that I wrote in PHP and XML that will give information to the user about the classic car collections in the past. The data is being stored in XML file  and I retrieve the records using PHP as my programming language.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

People here in the Philippines can reach me at my mobile number 09173084360.

Thank you very much and Happy Programming.






Sample Program Output

index.php


<!-- Selecting a value in PHP and XML           -->
<!-- June 7, 2015   Sunday                      -->
<!-- Written By: Mr. Jake R. Pomperada, MAED-IT -->
<!-- Email Address: jakerpomperada@gmail.com    -->
<!--              : jakerpomperada@yahoo.com    -->
<html>
<title>Car Collection in PHP and XML
</title>
<style>
h1 {
    font-family:arial;
color:blue;
};

</style>

<body bgcolor="yellow">
<br><br>
<h1>
Car Collection in PHP and XML
</h1>
<form method="post" action="">
<select id="select" class="select" name="filter1" style="text-align:center;">
<option value="1" <?php if(@$_POST['filter1'] == '1') { echo 'selected = \"selected\"'; } ?>>Car Series One</option>
<option value="2"  <?php if(@$_POST['filter1'] == '2') { echo 'selected = \"selected\"'; } ?>>Car Series Two</option>
</select>
<input type="submit" id="submit" name="submit" value="ok" title="Click here to select your choice.">
</form>
<br>
<?php 
if(isset($_POST['submit'])){

if($_POST['filter1'] == "1")
{
$xml = simplexml_load_file("car1.xml");

         foreach($xml->children() as $automobile)
              {
                  echo "<font color='blue' face='arial' size='3'>Car Name   : ".$automobile->name."<br />";
                  echo "Year    : ".$automobile->year." <br />";
 echo "Price  : ".$automobile->price." <br />";
        echo " Description : ".$automobile->description." <br /> </font>";
echo "<br><br>";
                }             
        }

else if ($_POST['filter1'] == "2")
{
$xml = simplexml_load_file("car2.xml");
       
  foreach($xml->children() as $automobile)
              {
               echo "<font color='blue' face='arial' size='3'>Car Name   : ".$automobile->name."<br />";
               echo "Year    : ".$automobile->year." <br />";
  echo "Price  : ".$automobile->price." <br />";
      echo " Description : ".$automobile->description." <br /> </font>";
   echo "<br><br>";
               
             }
  }

}
?>

</body>
</html>


car1.xml

<?xml version="1.0"?>
<cars>
   <automobile id="1">
      <name>Studebaker President Eight Roadster </name>
      <year> 1929 </year>
       <price>$1,895</price>
       <description>
   Studebaker 1929 President Eight Roadster seats two
in the comfortable front seats and two in the Rumble
, 115 Horsepower engine, hydraulic shock absorbers, wire wheels,
spare tire and bumpers are additional 
to the price. 
   </description>
   </automobile>

   <automobile id="2">>
      <name>Chevrolet</name>
      <year> 1924 </year>
       <price>$525.00</price>
       <description>
   By the middle of the decade Chevrolet had joined the auto mass production 
era and although the cars were more expensive than Ford's at the time many of 
those things that cost extra on the Ford were included, the basic specs were Standard 
Transmission with 3 forward and 1 reverse gear, Standard Electrical System which 
included electric starter, electric lights front and rear, large radiator and fan, 
speedometer, ammeter, oil pressure gauge,choke pull, starting switch, plus an extra tire 
rim was included mounted on the rear of the car
   </description>
   </automobile>
   
    <automobile id="3">>
      <name>Buick Marquette </name>
      <year> 1930</year>
       <price>$965.00</price>
       <description>
 The Buick Marquette features a 67.5 horsepower engine that 
 races from 0 to 60 in just 31 seconds. The Buick Marquette offers 
 easy vibration free motoring at 70 MPH, also featuring 4 wheel brakes 
 working on 12 inch drums, 4 hydraulic shock absorbers ensure a 
 smooth ride over all surfaces. Bodies are manufactured by Fisher 
   </description>
   </automobile>
   
   <automobile id="4">>
      <name>Gray Motor Company Coach </name>
      <year> 1923</year>
       <price>$785</price>
       <description>
1923 Gray Motor Company Coach features a four cylinder engine, 
3 speed transmission, lightening ignition from Westinghouse, 
4 wheel shock absorbing springs,comes in 4 options starting at $495 for
the Roadster to the 4 door sedan costing $835.00 
   </description>
   </automobile>
     

</cars>

car2.xml

<?xml version="1.0"?>
<cars>
   <automobile id="1">
      <name>Dodge Brothers De-Luxe Sedan   </name>
      <year> 1926</year>
       <price>$1,075</price>
       <description>
   Dodge Brothers auto's are known for their top quality materials used 
in each and every auto with the finest Chrome Vanadium used from the Axles 
to the engine, and Mohair Interior of the finest quality offering long life 
and dependability for your purchase. 
   </description>
   </automobile>

   <automobile id="2">>
     <name>Cadillac 90 Degree </name>
      <year> 1927</year>
       <price>$2,995</price>
       <description>
   Cadillac Prestige Pointing the way to Luxury, Distinction and motor car value 
that brings abiding satisfaction.
   </description>
   </automobile>
   
    <automobile id="3">
       <name>Chrysler 75 Roadster </name>
      <year> 1928</year>
       <price>$1,555</price>
       <description>
 The new Chrysler 75 Roadster for 1928, one the most attractive cars of 
 our times made by master craftsmen entering a new era in design and craftsmanship. 
   </description>
   </automobile>
   
   <automobile id="4">
     <name>Horse Drawn Auto Seat Top Buggy  </name>
      <year> 1905</year>
       <price> $86.70 </price>
       <description>
   I have included this example because it shows how traditional 
horse drawn carriage manufacturers were trying to survive, one
of the most interesting selling points for this carriage was that
the wheel base size was the same as most of the smaller autos of the 
day 4ft 8 inches, and if you look the sitting position and layout was
very similar although higher off the ground. 
  </description>
      </automobile>
</cars>


Selecting a Value in PHP and XML

In this sample program I will show you how to select a value from a drop down menu in HTML and extract the data in an XML file. This will be my first time to write a program that uses XML and PHP. According to Wikipedia.org XML is defined as Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format which is both human-readable and machine-readable. It is defined by the W3C's XML 1.0 Specification and by several other related specifications, all of which are free open standards.

The code is very easy to follow and understand I hope you will find my work useful in your programming projects and assignments. If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.

People here in the Philippines can contact me at my mobile number 09173084360.

Thank you very much and Happy Programming.




Program Listing

index.php

<!-- Selecting a value in PHP and XML           -->
<!-- June 7, 2015   Sunday                      -->
<!-- Written By: Mr. Jake R. Pomperada, MAED-IT -->
<!-- Email Address: jakerpomperada@gmail.com    -->
<!--              : jakerpomperada@yahoo.com    -->
<html>
<title>Selecting a value in PHP and XML
</title>
<style>
h1 {
    font-family:arial;
color:blue;
};

</style>
<body bgcolor="lightgreen">
<br><br>
<h1>
SELECTING A VALUE IN PHP AND XML
</h1>
<form method="post" action="">
<select id="select" class="select" name="filter1" style="text-align:center;">
<option value="1" <?php if(@$_POST['filter1'] == '1') { echo 'selected = \"selected\"'; } ?>>First Record</option>
<option value="2"  <?php if(@$_POST['filter1'] == '2') { echo 'selected = \"selected\"'; } ?>>Second Record</option>
<option value="3" <?php if(@$_POST['filter1'] == '3') { echo 'selected = \"selected\"'; } ?> >Third Record</option>
<option value="4" <?php if(@$_POST['filter1'] == '4') { echo 'selected = \"selected\"'; } ?>>Fourth Record</option>
</select>
<input type="submit" id="submit" name="submit" value="ok" title="Click here to select your choice.">
</form>
<br>
<?php 
if(isset($_POST['submit'])){
if($_POST['filter1'] == "1")
{
$users = simplexml_load_file("1.xml");

            foreach ($users->person as $item)
              {
   
                if ($item->id == 1)  {
                  echo "<font color='blue' face='arial' size='5'>Title   : ".$item->title."<br />";
                  echo "Name    : ".$item->name." <br />";
        echo "Address : ".$item->address." <br /> </font>";
                }
             }
        }
else if ($_POST['filter1'] == "2")
{
$users = simplexml_load_file("1.xml");

            foreach ($users->person as $item)
              {
   
                if ($item->id == 2)  {
                  echo "<font color='blue' face='arial' size='5'>Title   : ".$item->title." <br />";
                  echo "Name    : ".$item->name." <br />";
         echo "Address : ".$item->address." <br /> </font>";
                }
             }
  }
else if ($_POST['filter1'] == "3")
{
    $users = simplexml_load_file("1.xml");

            foreach ($users->person as $item)
              {
   
                if ($item->id == 3)  {
                  echo "<font color='blue' face='arial' size='5'> Title   : ".$item->title." <br />";
                  echo "Name    : ".$item->name." <br />";
         echo "Address : ".$item->address."</font> <br />";
                }
             }
 }  
else if ($_POST['filter1'] == "4")
{
 $users = simplexml_load_file("1.xml");
       foreach ($users->person as $item)
              {
   
                if ($item->id == 4)  {
                  echo "<font color='blue' face='arial' size='5'> Title   : ".$item->title." <br />";
                  echo "Name    : ".$item->name." <br />";
         echo "Address : ".$item->address."</font> <br />";
                }
             }
 
  } 
else {
     echo "No Selected Records.";
}

 }
?>

</body>
</html>

1.xml

<?xml version="1.0"?>
<information>
   <person>
     <id> 1 </id>
     <title> First Record </title>
<name> Ana Maria Tan </name>
<address> Cubao, Quezon City </address>
   </person>

  <person>
     <id> 2 </id>
     <title> Second Record </title>
<name> David Smith </name>
<address> Washington Street, Iloilo City </address>
   </person>
   
   
  <person>
    <id> 3</id>
     <title> Third Record </title>
<name> Linda Lee </name>
<address> Hongkong, China </address>
   </person>
   
  
  <person>
     <id> 4 </id>
     <title> Fourth Record </title>
<name> Adam Stone </name>
<address> West Avenue, United Kingdom </address>
   </person>
 </information>