Functions

Lab 12/6/12

No chapter lab today

Pocket Calculator

  1. Your calculator should have an input element of type text with id attribute accumulator.
  2. It should have 10 digit buttons: input elements of type button with value attributes 0 through 9 and id attributes key_0 through key_9.
  3. It should have 4 function buttons with id attributes plus, minus, times, and divide.
  4. It should have (at least) 2 more buttons with id attributes clear and enter.
  5. Clicking the clear button should cause the accumulator value to get set to the empty string.
  6. Clicking a digit button should cause the digit to get appended to the accumulator value.
  7. Clicking a function button should cause the accumulator value saved in a local variable and the operation to get saved in another. The accumulator should also be cleared.
  8. Clicking the enter button should cause the saved value and the current value of the accumulator to be combined using the saved operation. The result should now appear in the accumulator.
  9. Test your calculator and save it in a calculator.html file in a Chapter18 subdirectory of your LABS directory.
  10. Edit the index.html file in your LABS directory to have a link to your calculator.html page.

Always turn off your computer and screen before leaving the room.