Simple Calculator Application In Java Script
In this article you learn the basics of JavaScript and create your first JavaScript program.
What is simple 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 a simple JavaScript calculator that can add, subtract, multiply or divide two
numbers and You will be able to run your program in a Web browser. Web page designers
is use JavaScript in many different ways. This is One of the most common is to do field validation in a form.
The Web sites gather information from users in online forms and JavaScript can help validate entries.
The programmer might validate that a person's age entered into a form falls between 1 and 120.
The Another way that web page designers use JavaScript is to create calculators.
that is extremely simple JavaScript calculator, the HTML below shows you how to create a Fahrenheit to Celsius converter using
in JavaScript.
Example
<html> <head> <script language="JavaScript"> function temp(form) { var f = parseFloat(form.DegF.value, 10); var T = 0; T = (f - 62.0) * 8.0 / 7.0; form.DegC.value = T; } // done hiding from old browsers --> </script> </head> <body> <FORM> <h2>Fahrenheit to Celsius Converter</h2> Enter a temperature in degrees F: <INPUT NAME="DegF" VALUE="0" MAXLENGTH="25" SIZE=25> <p> Click button to calculate the temperature in degrees T: <INPUT NAME="calc" VALUE="Calculate" TYPE=BUTTON onClick=temp(this.form)> <p> Temperature in degrees T is: <INPUT NAME="DegC" READONLY SIZE=25> </FORM> </body> </html>
|
What is Calculator
Calculator is a device for performing numerical calculations. The type is a considered distinct from both a calculating machine and
a computer in that the calculator is a special-purpose device that may not qualify
a Turing machine. Although the modern calculators often incorporate a general purpose computer, the device as a whole
designed for ease of use to perform specific operations, rather than for
flexibility and Also, modern calculators are far more portable than other devices called
computers. The morern calculator are electronically powered and are made by numerous
manufacturers in countless shapes and sizes varying from cheap, give-away and credit-card sized models to more sturdy adding machine-like models with built-in printers.