In this article I would like to share with you a simple program that will ask the user to give three numbers and then it will find the total sum of the three numbers using Java Server Pages or JSP. The code is very simple and easy to understand. I hope you will find my work useful thank you very much for visiting my blog.
My mobile number here in the Philippines is 09173084360.
I am currently accepting programming work kindly contact me in the following email address for further details. Thank you.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Sample Program Output
Program Listing
index.htm
<html>
<head>
<title>Addition of Three Numbers in Java Server Pages</title>
</head>
<body>
<br>
<h2> Addition of Three Numbers in Java Server Pages </h2>
<b><i> Created By Mr. Jake R. Pomperada <b> </i>
<br><br>
<form action="./add.jsp">
First number : <input type="text" name="t1"/> <br>
Second number : <input type="text" name="t2"/> <br>
Third number : <input type="text" name="t3"/>
<br><br>
<input type="submit" value="Sum" alt="Click her to compute the sum of three numbers." />
</form>
</body>
</html>
add.jsp
<html>
<head>
<title>Enter two numbers to add up</title>
</head>
<body>
<%!
String val1;
String val2;
String val3;
int val1_int;
int val2_int;
int val3_int;
int sum;
%>
<%
val1 = request.getParameter("t1");
val1_int = Integer.parseInt(val1);
val2 = request.getParameter("t2");
val2_int = Integer.parseInt(val2);
val3 = request.getParameter("t3");
val3_int = Integer.parseInt(val3);
sum = (val1_int + val2_int + val3_int);
%>
<br>
<h3> The total sum is <%= sum %>. </h3>
</body>
</html>
No comments:
Post a Comment