Showing posts with label math operations in JSP. Show all posts
Showing posts with label math operations in JSP. Show all posts

Sunday, June 21, 2015

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>