Android Calculator

Features
  1. Display temporary result while entering number
  2. Accept number 0-9 key, decimal and four math operator keys
  3. Back key
  4. Keep appending string calculation like in Android stock calculator. Example, 1+2*2
  5. Order of calculation is BODMAS. Example, 1+2*2=5 (not 6). For Window calculator, result is 6.
Design - Flow Chart
Coding Techniques Used
  • Main function - One addEventListener for the 0-9 keys, decimal key and all four operator (+ - * /) keys are dynamically generated using foreach loop
  • Some Javascript built-in function used: eval(), split(), includes()
  • Main Design Ideas: Check key type and last number string.
  • CSS Grid Layout
  • More comment in the code.
Source Code Summary
  • Total small functions: 5
  • Total anonymous functions: 2
  • Total lines of code: 162 (excluding comment)
Test Cases