Sunday, June 28, 2015

Average Quizzes Solver in Java

This is a very simple program that will compute the average quizzes of the student based on five quizzes given by their teacher that I wrote in Java programming language. The code is very simple but it uses already the concepts of object oriented programming.

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

import java.util.Scanner;


class five_test {
    public int find_five_average(int a, int b, int c, int d, int e)
    {
        int average=0;
        average=(a+b+c+d+e)/5;
        return(average);     
    }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of an quizzes object
  
  five_test quizzes = new five_test();
      
  System.out.println();
  System.out.println("===== AVERAGE QUIZZES SOLVER =====");
  System.out.println();
  System.out.print("Enter Score on Quiz Number 1 :  ");
  int quiz_one =   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 2 :  ");
  int quiz_two=   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 3 :  ");
  int quiz_three =   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 4 :  ");
  int quiz_four =   scan.nextInt();
  System.out.print("Enter Score on Quiz Number 5 :  ");
  int quiz_five =   scan.nextInt();
  
  System.out.println();

  System.out.print("The total average of five quizzes is " +
  quizzes.find_five_average(quiz_one,quiz_two,quiz_three,quiz_four,quiz_five)+  ".");
  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



Triangle Pattern in Java

A simple program that I wrote in Java that will display a triangle pattern on the screen using for loop statements.

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

class pattern_one {

  public static void main(String args[]) {
 int a=10;
 int b=1;
 System.out.println("\n\n");
 System.out.print("TRIANGLE PATTERN ONE");
 System.out.println("\n\n");
 for(int i=1; i<=a; i++)
 {
  for (int j=a-1;j>=i; j--)
  {
  System.out.print(" ");
  }
   for (int k=1; k<=b; k++){
    System.out.print("*");
   }
 b++;
System.out.println();
 }
}

  } // End of Program


Inches To Centimeter Converter in Java

In this article I would like to share with you a sample program that I wrote in Java programming language Inches To Centimeter Converter.  The program will ask the user to enter a value in inches and then it converted it to its centimeter equivalent.  

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

import java.util.Scanner;
import java.text.DecimalFormat;


class inches_to_centimeter
{

  public static double convert_to_centimeters(double inches)
   {
   double solve_centimeters = (inches * 2.54);
   return(solve_centimeters);
   }


 public static void main(String args[])
 {
     Scanner scan = new Scanner(System.in);
     DecimalFormat df = new DecimalFormat("###.##");
      char a;

  do
    {

    System.out.print("\n");
    System.out.println("==============================================");
    System.out.println("||    <<< Inches To Centimeter Converter  >>>  ||");
    System.out.println("==============================================");
    System.out.print("\n");
    System.out.print("How many length in inches? :=> ");
      double get_inches =   scan.nextDouble();

    System.out.println("\n");
    System.out.println("=======================");
    System.out.println("||  DISPLAY RESULT   ||");
    System.out.println("=======================");
    System.out.println("\n");
    System.out.print("The given length in inches is " + df.format(get_inches) + 
  " the equivalent length in centimeters is " +df.format(convert_to_centimeters(get_inches))+ " cms.");
    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

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>