Sunday, June 28, 2015

Reverse a Number in Java Version 2

A simple program that will ask the user to enter a number and then it will reverse the arrangement of number given by the user.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 reverse_number {
    public int reverse_given_number(int number)
    {
         
        int reverse = 0;
        while(number != 0){
            reverse = (reverse*10)+(number%10);
            number = number/10;
        }
        return reverse;
    }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of value object
  
   reverse_number value = new reverse_number();
      
  System.out.println();
  System.out.println("===== REVERSE A NUMBER =====");
  System.out.println();
  System.out.print("Enter a Number :  ");
  int number_value =   scan.nextInt();
  
  System.out.println();

  System.out.print("The given number is " + number_value + 
  " it's reverse order will be " +value.reverse_given_number(number_value)+ ".");
    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



Basic Math Operations in Java

A simple program that I wrote that I called Basic Math Operations in Java that will show you basic mathematical operations like addition, subtraction, multiplication and division using 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 basic_math {
    public static int math_operations(int a, int b)
    {
       int sum = (a + b);
       int difference = (a-b);
       int product = (a * b);
       int quotient = (a/b);
       
      System.out.println("The sum of " + a + " and " + b + " is " + sum +".");
      System.out.println("The difference of " + a + " and " + b + " is " + difference +".");
      System.out.println("The product of " + a + " and " + b + " is " + product +".");
      System.out.println("The quotient of " + a + " and " + b + " is " + quotient +".");
      return 0;
     }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
  do
    {
    System.out.println();
    System.out.println("===== BASIC MATH OPERATIONS =====");
    System.out.println();
    System.out.print("Enter two numbers : ");
    int x = scan.nextInt();
    int y = scan.nextInt();
      
     math_operations(x,y); 

    System.out.println("\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


Money Bills Denomination Counter in Java

A simple program that I wrote in Java that will count how many money bills in a given amount of money. It uses % or modulo operator of Java to achieve its results.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 bills{
    public static int count_bills(int amount)
    {
   int solve_thousand=0,solve_five=0,solve_two=0,solve_one=0;
   int remainder_thousand=0,remainder_five=0;
   int remainder_two=0,remainder_one=0;

   solve_thousand =(amount/ 1000);
   remainder_thousand = solve_thousand % 1000;

   solve_five =(amount/ 500);
   remainder_five = solve_five % 500;

   solve_two =(amount/ 200);
   remainder_two = solve_two % 200;

   solve_one =(amount/ 100);
   remainder_one= solve_one % 200;
   
   System.out.println("\n");
   System.out.println("Number of Php 1000 Bill(s) :=> " +  remainder_thousand);
   System.out.println("Number of Php 500  Bill(s) :=> " +  remainder_five);
   System.out.println("Number of Php 200  Bill(s) :=> " +  remainder_two);
   System.out.println("Number of Php 100  Bill(s) :=> " +  remainder_one);
   return 0;
   }

public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
  do
    {
    System.out.println();
    System.out.println("===== MONEY BILLS DENOMINATION COUNTER =====");
    System.out.println();
    System.out.print("Enter the Amount : Php  ");
    int amount = scan.nextInt();

    count_bills(amount);      
    System.out.println("\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




Armstrong Checker in Java

A simple program that I wrote using Java programming language that will check if the number given by the user is an armstrong number or not. 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 armstrong_checker {
    public int check_armstrong_number(int value)
    {
       int temp = value;
int sum = 0;
int mod = 0;
while(temp != 0) {
mod = temp % 10;
sum = sum + (mod * mod * mod);
temp = temp / 10;
}
if(sum == value) 
System.out.println("The given number " + value + " is  Armstrong Number.");
else
System.out.println("The given number " + value + " is Not an Armstrong Number.");
    return 0;
    }


public static void main(String args[]) {
  Scanner scan = new Scanner(System.in);
   char a;
do
    {
  // creating of an object
  
  armstrong_checker number = new armstrong_checker();
      
  System.out.println();
  System.out.println("===== ARMSTRONG NUMBER CHECKER =====");
  System.out.println();
  System.out.print("Enter a Number :  ");
  int number_given =   scan.nextInt();
  
  System.out.println();
  number.check_armstrong_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


















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>