May 23, 2008 at 4:54 PM
Hi vijay
<html>
<head>
<title>calculator program in jsp</title>
<script>
function checkValue(){
var msg = "";
if (f1.operand1.value == "" || f1.operand2.value == "")
msg += "Operands missing\n";
if (f1.op.selectedIndex == 3 && f1.operand2.value == 0)
msg += "Division by zero";
if (msg.length > 0){
alert(msg);
return false;
} else
return true;
}
</script>
</head>
<body>
<%
String str = "0",op2 = "0";
int result = 0;
String op = "+";
char opchar = op.charAt(0);
if (request.getParameter("op") != null){
op = request.getParameter("op");
opchar = op.charAt(0);
str = request.getParameter("operand1");
op2 = request.getParameter("operand2");
switch(opchar){
case '0': result = Integer.parseInt(str) + Integer.parseInt(op2);
break;
case '1': result = Integer.parseInt(str) - Integer.parseInt(op2);
break;
case '2': result = Integer.parseInt(str) * Integer.parseInt(op2);
break;
case '3': result = Integer.parseInt(str) / Integer.parseInt(op2);
break;
case '4': result = Integer.parseInt(str) % Integer.parseInt(op2);
break;
}
}
%>
<center>
<h2>Simple calculator program in jsp</h2>
<form method ="get" name ="f1" onsubmit = "return checkValue()">
<input type ="text" size ="20" name ="operand1" value = <%= str %> />
<select name = op size = 1>
<option value = "0" <% if (opchar == '0') out.print("selected"); %> >+</option>
<option value = "1" <% if (opchar == '1') out.print("selected"); %> >-</option>
<option value = "2" <% if (opchar == '2') out.print("selected"); %> >*</option>
<option value = "3" <% if (opchar == '3') out.print("selected"); %> >/</option>
<option value = "4" <% if (opchar == '4') out.print("selected"); %> >/</option>
</select>
<input type ="text" size="20" name ="operand2" value = <%= op2 %> />
<p>
<input type = submit value = Calculate />
Result = <%= result + "" %>
</form>
</body>
</html>
------------------------------
Read for more information.
http://www.roseindia.net/jsp/
Related Tutorials/Questions & Answers:
CalculatorCalculator need a simple java program to degin a
CALCULATOR without using ADVANCED JAVA....
Calculator in Java Swing
calculator midletcalculator midlet give me code
calculator midlet in bluetooth application with j2me
Advertisements
Calculator classCalculator class I am a beginner in Eclipse. I have to do a program called
calculator that adds numbers. This is my code so far:
//Margaret
//ICS... class
Calculator extends JFrame implements ActionListener {
JTextField text
ModuleNotFoundError: No module named 'Calculator'ModuleNotFoundError: No module named '
Calculator' Hi,
My Python... '
Calculator'
How to remove the ModuleNotFoundError: No module named '
Calculator' error?
Thanks
Hi,
In your python environment you
calculator - Java Interview Questionscalculator create
calculator by java code Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/example/java/swing/
calculator-in-swing.shtml
Thanks
Program for Calculator - Swing AWTProgram for Calculator write a program for
calculator? Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/example/java/swing/
calculator-in-swing.shtml
Hope that it will be helpful
PHP Tax Calculator - PHPPHP Tax Calculator In my project i required a tax
calculator that can calculate the property tax
simple calculator - Java Beginnerssimple calculator how can i create a simple
calculator using java codes? Hi Friend,
Please visit the following link:
http://www.roseindia.net/java/example/java/swing/
calculator-in-swing.shtml
Thanks
Calculator - JSP-ServletCalculator Dear Deepak Sir,
Calculator program is avilable in Jsp...
calculator program in jsp
function checkValue(){
var msg...;
}
Simple
calculator program in jsp
/>
>
Scientific Calculator - Java BeginnersScientific Calculator Develop a scientific
calculator using even-driven programming paradigm of Java.?
Thanks in ADVANCE Hi Friend,
Please visit the following link:
http://www.roseindia.net/tutorial/java
matrix calculator - Java Beginnersmatrix calculator hi.....
can you help me in writing source code of matrix
calculator in java...
i know you are the best you can do it!!! show yourself