- Skill level:
Other People Are Reading
Things you need
- Text editor
Open your text editor, which must be set to "plain text" mode. Examples of appropriate text editors include Notepad for Microsoft Windows and TextEdit for Mac OS X.
Create your HTML document. Include a table that has three sections: one for numerical input buttons; another for operation buttons; and a section for displaying input and output. Create input buttons for each number (0 through 9), a decimal point and buttons for each operation (addition, subtraction, multiplication, division, exponents, etc.) that you want to be able to perform with your calculator.
Define all global variables and constants. These variables should include a maximum length constant, a memory variable for storing the previously entered value, a current variable for storing the entered value and a variable for storing the operation.
Define functions for each operation (i.e. addition, subtraction, etc.), clearing the input, putting a decimal point in the input and a function for performing the desired calculation.
Include a function that is called in the division function to ensure that the user does not attempt to divide by zero. If this is attempted, include a warning message of some type.
Tips and warnings
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for