Sunday, May 29, 2016

Average of Three Numbers in JSTL

A simple program that I wrote using JSTL or Java Server Pages Standard Tag Library that will ask the user to give the number three numbers and then our program will compute the average of the three numbers. The code is very simple 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





Sample Program Output


Program Listing

average_numbers.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
<title>Average of Three Numbers in JSTL</title>
</head>
<style>
body 
{
font-family:arial;
font-weight:bold;
size:12px;
color:blue;
}
</style>
<body>
  <h2> Average of Three Numbers in JSTL</h2>
  <br>
  <form method="post">
     Enter Fist Number &nbsp; &nbsp;
    <input type="text" name="one"  size="3" value="<c:out value="${param.one}"/>" autofocus/><br>
    Enter Second Number &nbsp; &nbsp;
    <input type="text" name="two"  size="3" value="<c:out value="${param.two}"/>"/> <br>
     Enter Third Number &nbsp; &nbsp;
    <input type="text" name="three"  size="3" value="<c:out value="${param.three}"/>"/>
   <br> <br>
     <input type="submit" value="Find Average"  title="Click here to findout the average of the three numbers." />
     <br />
    </form>
<c:if test="${pageContext.request.method=='POST'}">
 <c:set var="average" scope="session" 
 value="${ (param.one + param.two + param.three) /3}"/>
 <br>

The average of <c:out value="${param.one}"/>,
 <c:out value="${param.two}"/> and <c:out value="${param.three}"/>
 is <fmt:formatNumber value="${average}" maxFractionDigits="2"/>.
</c:if>
</body>
</html>

Simple Payroll Program in JSTL

A simple program that I wrote using JSTL or Java Server Pages Standard Tag Library that will ask the user to give the number of days work of the employee and then it will ask the rate per day and then our program will compute the salary of the employee. The code is very simple 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



Sample Program Output


Program Listing

payroll.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title>Simple Payroll Program in JSTL</title>
</head>
<style>
body 
{
font-family:arial;
font-weight:bold;
size:12px;
color:blue;
}
</style>
<body>
  <h2> Simple Payroll Program in JSTL</h2>
  <br>
  <form method="post">
     Enter Number of Days Work &nbsp; &nbsp;
    <input type="text" name="days"  size="3" value="<c:out value="${param.days}"/>" autofocus/><br>
    Enter Rate Per Day&nbsp; &nbsp;
    <input type="text" name="rate"  size="3" value="<c:out value="${param.rate}"/>"/>
   <br> <br>
     <input type="submit" value="Compute Salary"
     title="Click here to findout the salary of the employee." />
     <br />
    </form>
<c:if test="${pageContext.request.method=='POST'}">
 <c:set var="salary" scope="session" value="${param.days * param.rate}"/>
 <br>
Your salary is $<c:out value="${salary}"/>.
</c:if>
</body>
</html>



Positive and Negative Number Checker in JSTL

A simple program that I wrote that will check if the given number is an positive or negative number using JSTL or JSP Standard Tag Library. The code is very easy to understand and learn from it.

 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


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Positive and Negative Number Checker in JSTL</title>
</head>
<style>
body 
{
font-family:arial;
font-weight:bold;
size:12px;
color:blue;
}
</style>
<body>
  <h2> Positive and Negative Number Checker in JSTL</h2>
  <br>
  <form method="post">Enter a Number &nbsp; &nbsp;

    <input type="text" name="number" />
   <br> <br>
     <input type="submit" value="Check Number"
     title="Click here to find if the given number is Positive or Negative" />

    <br />
    </form>
<c:if test="${pageContext.request.method=='POST'}">
      <c:if test="${param.number >= 0}"> 
       <br /> <br /><br>
      The given number is POSITIVE.
     
      </c:if>
      <br /> <br /><br>
      <c:if test="${param.number < 0}"> The given number is NEGATIVE.
     
      </c:if>
    </c:if>
  
</body>
</html>

Odd and Even Number Checker in JSTL

A simple program that I wrote that will check if the given number is an odd or even number using JSTL or JSP Standard Tag Library. The code is very easy to understand and learn from it.

 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

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Odd and Even Number in JSTL</title>
</head>
<style>
body 
{
font-family:arial;
font-weight:bold;
size:12px;
color:blue;
}
</style>
<body>
  <h2> Odd and Even Number Checker in JSTL</h2>
  <br>
  <form method="post">Enter a Number &nbsp; &nbsp;

    <input type="text" name="number" />
   <br> <br>
     <input type="submit" value="Check Number"
     title="Click here to find if the given number is an ODD or EVEN" />

    <br />
    </form>
<c:if test="${pageContext.request.method=='POST'}">

      <c:if test="${param.number % 2 == 0}"> 
       <br /> <br /><br>
      You give an EVEN number.
     
      </c:if>
      <br /> <br /><br>
      <c:if test="${param.number % 2 != 0}"> You give an ODD number.
     
      </c:if>
    </c:if>
  
</body>
</html>


Addition of Three Numbers Using JSTL

A simple program that I wrote that will add the sum of the three numbers using JSTL or JSP Standard Tag Library. The code is very easy to understand and learn from it.

 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

index.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
body 
{
font-family:arial;
font-weight:bold;
size:12px;
color:blue;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Addition of Three Numbers in JSTL</title>
</head>
<body>
<h3> Addition of Three Numbers in JSTL</h3>
The sum of 10, 20 and 30 is  <c:out value="${10 + 20+ 30}" />.
</body>
</html>

Sunday, May 22, 2016

Factorial of Number Using Java Spring Framework

 A simple program that I wrote using Java Programming language and Spring Framework to get a number from the user and then compute for the factorial number value.

 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


TestSpringProject.java

package org.gontuseries.springcore;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestSpringProject {

public static void main(String[] args) {
 @SuppressWarnings("resource")
ApplicationContext context = 
 new ClassPathXmlApplicationContext("SpringConfig.xml");
 
 Factorial FactorialObj = (Factorial) context.getBean("Factorial_Bean");
    
 FactorialObj.solve();
}
}


Factorial.java

package org.gontuseries.springcore;

import java.util.Scanner;

public class Factorial {
int number=0, counter=0, fact_number = 1;
public void solve() {
 @SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
 System.out.println();
 System.out.println("Factorial Number in Java Spring Framework");
 System.out.println("\n");
   
 System.out.print("Give a Number : ");
     number = in.nextInt();
     
     if ( number < 0 )
            System.out.println("The give number should be positive.");
         else
         {
            for ( counter = 1 ; counter <= number ; counter++ )
               fact_number = fact_number *counter;
            
            System.out.println("\n");
            System.out.println("Factorial of "+ number +" is equal to "+fact_number+".");
         }
 
 System.out.println("\n");
 System.out.println("End of Program");
 
}

}


SpringConfig.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
           
<bean id="Factorial_Bean" class="org.gontuseries.springcore.Factorial">
</bean>

</beans>





Odd and Even Numbers Using Java Spring Framework

A simple program that I wrote using Java Programming language and Spring Framework to check if the given number by the user is an Odd and Even Number.

 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


TestSpringProject.java

package org.gontuseries.springcore;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestSpringProject {

public static void main(String[] args) {
 @SuppressWarnings("resource")
ApplicationContext context = 
 new ClassPathXmlApplicationContext("SpringConfig.xml");
 
 Odd_Or_Even Odd_Or_EvenObj = (Odd_Or_Even) context.getBean("Odd_Or_Even_Bean");
    
 Odd_Or_EvenObj.checking();
}
}


SpringConfig.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
           
<bean id="Odd_Or_Even_Bean" class="org.gontuseries.springcore.Odd_Or_Even">
</bean>

</beans>

Odd_Or_Even.java

import java.util.Scanner;

public class Odd_Or_Even {
int number=0;
public void checking() {
 @SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
 System.out.println();
 System.out.println("Odd or Even Number Checker in Java Spring Framework");
 System.out.println("\n");
   
 System.out.print("Give a Number : ");
     number = in.nextInt();
     
     if ( number % 2 == 0 ) {
            System.out.println("\n");
            System.out.println("The number " + number + " is an even number.");
     }
         else {
        System.out.println("\n");
            System.out.println("The number " + number + " is odd number.");
}

 
 System.out.println("\n");
 System.out.println("End of Program");
 
}

}



List of Numbers Without Using a Loop in C++

A simple program that I  wrote in C++ that will list down  a  number from one to fifty without using a looping statement in C++. 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.




Sample Program Output


Program Listing

#include <iostream>
#include <stdlib.h>

using namespace std;

int print(int num){
    if(num<=50){
         cout << " " << num << " ";
          print(num+1);
    }
}


int main(){
    int num = 1;
    cout << "\nList of Numbers Without Using a Loop in C++";
    cout <<"\n\n";
    print(num);
    cout <<"\n\n";
    cout << "\nEnd of Program";
    cout <<"\n\n";
    system("pause");

}



Sum of Digits in C++

A simple program that I wrote using C++ language as my programming language that will ask the user to give a number and then our program will add the sum of digits in a given number by our user. The code is very 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.


Sample Program Output


Program Listing

#include <iostream>
#include <stdlib.h>

using namespace std;


int main()
{
   int number=0, process=0, sum = 0, remainder=0;

   cout <<"\n\n";
   cout <<"\t Sum of Digits in C++ ";
   cout <<"\n\n";
   cout <<"Kindly give a number : ";
   cin >> number;

   process = number;

   while (process != 0)
   {
      remainder = (process % 10);
      sum = sum  + remainder;
      process = (process / 10);
   }

   cout <<"\n\n";
   cout <<"The total sum of digits is " << sum << ".";
   cout <<"\n\n";
   cout <<"End of Program";
   cout <<"\n\n";
   system("pause");
}

Sum of Digits in C

A simple program that I wrote using C language as my programming language that will ask the user to give a number and then our program will add the sum of digits in a given number by our user. The code is very 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.



Sample Program Output


Program Listing


#include <stdio.h>
#include <stdlib.h>

int main()
{
   int number=0, process=0, sum = 0, remainder=0;

   printf("\n\n");
   printf("\t Sum of Digits in C ");
   printf("\n\n");
   printf("Kindly give a number : ");
   scanf("%d", &number);

   process = number;

   while (process != 0)
   {
      remainder = (process % 10);
      sum = sum  + remainder;
      process = (process / 10);
   }

   printf("\n\n");
   printf("The total sum of digits is %d.", sum);
   printf("\n\n");
   printf("End of Program");
   printf("\n\n");
   system("pause");
}