Matrix Calculator


Build a cool-looking web calculator. Add the calculation buttons you need, wire them up and use CSS to skin your calculator to be your style. For an example click here


Directions
  1. Setup a webpage with a grid for buttons. Use divs to create rows. Add a class attribute: < div class="its_a_row"> so you can style them all together.

  2. Create 17 buttons: numbers 0-9, four main operators (+-/*), period, equal, clear.

  3. Think of the best layout for your calculator. Arrange them inside the rows as you prefer. Have all buttons run corresponding functions when you click on them.

    HINT: all the Number buttons can run the same function. So can all the Operator buttons.

  4. Create another div above the buttons. This will be the output screen.

  5. In JavaScript, wire up the number buttons: clicking on them should make the corresponding number appear in the screen.

  6. Wire up the operator buttons. Have the operator symbol appear in the screen, unless the screen is empty.

  7. Wire up the period and clear buttons.

  8. Now hook up the Equal button to produce the result. Hint: look at the eval() function.

  9. Put your screen and buttons in a simple table and give it a border to resemble a calculator.

  10. Style your buttons and screen with CSS. Add a cool background image.
    HINT: use button:hover and button:active to give your buttons responsive UI

  11. FOR EXTRA CREDIT:
    (1) Add a delete button to take out the last character typed

    (2) add Audio to each button press

    (3) With this version, all input is written directly to the screen. Try a version where each set of numbers is saved to a stack, like an accountant’s calculator.








(c) 2016 by Code Craft Academy