* * Your task is to create a calculator. You can create * your calculator using any of the DOM manipulation * techniques we learned throughout the semester. Use * javascript's eval function to perform the calculation. * If an error occurs, show ERROR on the calculator * 'screen'. * * Example of using eval: var result = eval('10+4*2'); * * Requirements: * - Buttons for every digit 0-9 * - Buttons for +, -, /, * * - Button to backspace or clear <- * - Button to execute calculation = * - Calculator 'screen' should update as buttons * are pressed including numbers, operations, etc * - Result should show on calculator 'screen' * - Upon submitting and showing result, calculator * should reset on next button click, starting new * calculation * - If an error occurs, for example inputting ---6, * calculator 'screen' should output 'ERROR' * - Calculator 'screen' should fit at least 10 * characters * - At least 12 CSS styles * * Submit your JS file, HTML file, and optional CSS/jquery * file. */
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
JavaScript: Use any of the techniques (including jQuery if you would like to). Be sure to upload your html, js, and css/jquery files if used.
/*
* Your task is to create a calculator. You can create
* your calculator using any of the DOM manipulation
* techniques we learned throughout the semester. Use
* javascript's eval function to perform the calculation.
* If an error occurs, show ERROR on the calculator
* 'screen'.
*
* Example of using eval: var result = eval('10+4*2');
*
* Requirements:
* - Buttons for every digit 0-9
* - Buttons for +, -, /, *
* - Button to backspace or clear <-
* - Button to execute calculation =
* - Calculator 'screen' should update as buttons
* are pressed including numbers, operations, etc
* - Result should show on calculator 'screen'
* - Upon submitting and showing result, calculator
* should reset on next button click, starting new
* calculation
* - If an error occurs, for example inputting ---6,
* calculator 'screen' should output 'ERROR'
* - Calculator 'screen' should fit at least 10
* characters
* - At least 12 CSS styles
*
* Submit your JS file, HTML file, and optional CSS/jquery
* file.
*/
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 9 images