Techknow Study

java calculator

5:52:00 PM vikas 0 Comments Category :

                     WAP in java script to create calculator.

Hey frnd what are you doing. Previously I gave you some idea about java programming.
Now i want share how to make a simple calculator in java. its gives you batter idea about how to deal with script and make a calculator like graphical widget.
enjoy this and make yourself a new GUI widget.


<meta http-equiv=”Content-Type” content=”text/html;charset=UTF-8”>
<script type=”javascript”>
Var inputstring=”;
Function updateString(x)
<title>JSP PAGE</title>
<form name=”calculator”>
<input type=”input” name=”input” size=”50”><br>
<input type=”button” name=”one” value=”1” size=”50” onclick=”updateString(‘1’)”>
<input type=”button” name=”two” value=”2” size=”50” onclick=”updateString(‘2’)”>
<input type=”button” name=”three” value=”3” size=”50” onclick=”updateString(‘3’)”></br>
<input type=”button” name=”four” value=”4” size=”50” onclick=”updateString(‘4’)”>
<input type=”button” name=”five” value=”5” size=”50” onclick=”updateString(‘5’)”>
<input type=”button” name=”six” value=”6” size=”50” onclick=”updateString(‘6’)”></br>
<input type=”button” name=”seven” value=”7” size=”50” onclick=”updateString(‘7’)”>
<input type=”button” name=”Eight” value=”8” size=”50” onclick=”updateString(‘8’)”>
<input type=”button” name=”nine” value=”9” size=”50” onclick=”updateString(‘9’)”></br>
<input type=”button” name=”zero” value=”0” size=”50” onclick=”updateString(‘0’)”>
<input type=”button” name=”plus” value=”+” size=”50” onclick=”updateString(‘+’)”>
<input type=”button” name=”sub” value=”-” size=”50” onclick=”updateString(‘-’)”><br>
<input type=”button” name=”multiply” value=”*” size=”50” onclick=”updateString(‘*’)”>
<input type=”button” name=”divide” value=”/” size=”50” onclick=”updateString(‘/’)”>
<input type=”button” name=”one” value=”=” size=”50” onclick=”input.value=eval(“inputstring”)”>