| |
Deliverables:
To complete this assignment you must --
- Write an HTML document with embedded Javascript according to the instructions.
- Email your instructor what you have completed. You can get partial credit even if not fully
completed with the lab.
Introduction:
The goal of this assignment is to give you experience working with functions.
You will create a simple calculator by programming the basic functions.
Procedures:
- Use a text editor to complete your assignment.
- Using your text editor create a new document named "cop2500lab6.html".
Use the document here as the starting point. You may change the arrangement to your liking, but there must be a method to input 2 numbers and at least the 4 buttons to select the operation as well as a method to confirm the result.
-
Using functions in Javascript, perform the operation the user clicks on and display the results in the form text box named answer.
Review Lab 6: Functions for help using functions.
Calculator
| Section | Pseudocode | Comments |
| INPUT: | var x, y; |
These are obtained from from text boxes n1 and n2. | |
| OTHER VARIABLES: | var result; |
| INITIALIZATION: | n1 and n2 must be provided by the
user. |
| |
| COMPUTATION: | Add: result = x + y; Subtract: result = x - y; Multiply: result = x * y; Divide: result = x / y; |
| |
| OUTPUT: | return(result); |
Remember to place the result in the form text box named answer |
-
Open a browser and verify that the file displays properly.
|