CMPS 335 Advanced Web Publishing
JavaScript Programming
Assignment 5, Spring, 2002
Simulating A Simple Calculator (HTML form and JavaScript)
Primary Objectives of the Assignment
- Using function (function definition and function call)
- Using if/else if/else and/or switch
- Using document.write, parseFloat, and ParseInt methods
Using HTML form elements, simulate a simple calculator as shown in
the example below. Use JavaScript code to accomplish compuitational
tasks of the calculator.
The calculator should have the following form elements:
- Two input boxes to accept two numbers.
- A set of radio buttons for the user to select one of the operations
to perform.
- A Submit button with a "Calculate" label and a Reset button with
a "Start Over" label..
(An example of the simulated calculator)
Online Examples:
A simple
calculator (jsCalculator1.html - using the if statement)
A simple
calculator (jsCalculator2.html - using the switch statement)
A better
calculator (jsCalculator3.html - using the switch statement)
Return to CMPS 335 Main Page
Return to Web Site Home Page