Question: Calculator

vijayababu
Calculator
Posted in : JSP-Servlet

May 23, 2008 at 4:54 PM

Hi vijay

<html>
<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){
return false;
} else
return true;
}
</script>

<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>

------------------------------

http://www.roseindia.net/jsp/

Calculator
Calculator  need a simple java program to degin a CALCULATOR without using ADVANCED JAVA....   Calculator in Java Swing
calculator midlet
calculator midlet  give me code calculator midlet in bluetooth application with j2me
Calculator class
Calculator 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
simple calculator program in javascript
simple calculator program in javascript  strong textsimple calculator in javascript
thread program for calculator implementation  Hi i'm prem i need calculator progrm in java that are implemented by Thread interface.....pls strong text
base calculator.. - Java Beginners
base calculator..  Help, i need some help about a base calculator.. i don't know how to start
Program for Calculator - Swing AWT
Program 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
calculator - Java Interview Questions
calculator  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
PHP Tax Calculator - PHP
PHP Tax Calculator  In my project i required a tax calculator that can calculate the property tax
simple calculator - Java Beginners
simple 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-Servlet
Calculator  Dear Deepak Sir, Calculator program is avilable in Jsp... calculator program in jsp function checkValue(){ var msg...; } Simple calculator program in jsp /> >
calculator - Java Server Faces Questions
calculator  Some ideas for the project of calculator
matrix calculator - Java Beginners
matrix 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
Scientific Calculator - Java Beginners
Scientific 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
How to write calculator in J2ME program?
How to write calculator in J2ME program?  How to write calculator in J2ME program
calculator in java with stack
calculator in java with stack  i want calcultor with interface in java and in interface there is button called postfix ,,, when the user enter opertions and numbers first check if is vaild or not then convert to postfix
base calculator.. - Java Beginners
base calculator..  need some help!!! I cant install jcreator properly?? there's always an error (Error : Invalid path, "C:\Program Files\Java\jre1.6.0_01\bin\javac.exe" -classpath "C:\Program Files\Java\jdk1.6.0_01\bin" -d "C
Java Calculator Program
Java Calculator Program  Hi, so I need to make a program that "works like a calculator". I need to make two versions: 1) I'm given the Expression Class and need to implement the children classes, which are Number, Product, Sum
Design and Implement GPA Calculator
Calculator"); //frame.setLayout(new BorderLayout()); frame.setLayout...); headingLabel = new JLabel("Welcome To GPA Calculator
swimming pool calculator
Simple Java Calculator - Java Beginners
Calculator for 4 basic Math operations, Addition, Subtraction, Multiplication and Division. The calculator should simulate the look of handheld calculator containing.... Write proper code for making this calculator operational. Students
Java Calculator program - Java Beginners
Java Calculator program  import java.awt.*; import javax.swing.*; import java.awt.event.*; class Calculator implements ActionListener { int c,n...; Calculator() { f=new Frame("Calculator"); p=new Panel(); b1=new JButton("0
HTML Calculator
HTML Calculator In this example we will learn how to make HTML Calculator. We have used HTML language in this example. First off all we have created one...;. This calculator can be used to perform simple mathematical operations like
Swimming Pool Calculator - Java Beginners
Calculator is one that is very simple to use. As you can see, it is a user... PoolVolume() { mainFrame = new JFrame("Swimming Pool Volume Calculator
Writing Calculator Stateless Session Bean
Writing Calculator Stateless Session Bean... for our Calculator Session Bean:   /* * ...; <session > <description>EJB Calculator Session
Java Swing Scientific Calculator
Java Swing Scientific Calculator A Scientific Calculator is a very powerful and general purpose calculator. In addition to basic arithmetic functions... calculator using java swing. Here is the code: import java.awt.*; import
java loan calculator applet help
java loan calculator applet help  Hi, I could use some help correcting a code here. I need to write a Java applet program (together with its html test file) to calculate loan payments. The user will provide the interest rate
Swimming Pool Calculator - Java Beginners
()); mainFrame = new JFrame("Swimming Pool Volume Calculator"); calcButton = new
Swimming Pool Calculator - Java Beginners
Calculator", tempCalc ); jtabbedPane.addTab( "Customers", customers
Simple Calculator Application In Java Script
Simple Calculator Application In Java Script  ... Calculator The objective of this project is  learn how to write a simple calculator with the JavaScript programming language. You will learn how to write
Tutorials