COP2500 Lab 5

Deliverables: To complete this assignment you must --

  1. Write the HTML and JavaScript page described below and demonstrate to the lab instructor that it operates correctly.
  2. If you do not finish in the lab, email your instructor showing 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 simple calculator by programming the basic functions.


Procedures:
  1. Use a text editor to complete your assignment.
  2. Using your text editor create a new document named "cop2500lab5.html". Do not close out the window until after the lab instructor has had time to verify your work. Use the document here as the starting point
  3. Convert the following four algorithms into JavaScript functions within your HTML document. Display the results in the form text box named answer.

    Add(x, y)
    SectionPseudocodeComments
    INPUT:Integer x, y; These are obtained from from text boxes n1 and n2.
    OTHER VARIABLES:Number result;
    INITIALIZATION: n1 and n2 must be provded by the user.
    COMPUTATION: result = x + y;
    OUTPUT:return(result); Remember to place the result in the form text box named answer

    Subtract(x, y)
    SectionPseudocodeComments
    INPUT:Integer x, y; These are obtained from from text boxes n1 and n2.
    OTHER VARIABLES:Number result;
    INITIALIZATION: n1 and n2 must be provded by the user.
    COMPUTATION: result = x - y;
    OUTPUT:return(result); Remember to place the result in the form text box named answer

    Multiply(x, y)
    SectionPseudocodeComments
    INPUT:Integer x, y; These are obtained from from text boxes n1 and n2.
    OTHER VARIABLES:Number result;
    INITIALIZATION: n1 and n2 must be provded by the user.
    COMPUTATION: result = x * y;
    OUTPUT:return(result); Remember to place the result in the form text box named answer

    Divide(x, y)
    SectionPseudocodeComments
    INPUT:Integer x, y; These are obtained from from text boxes n1 and n2.
    OTHER VARIABLES:Number result;
    INITIALIZATION: n1 and n2 must be provded by the user.
    COMPUTATION: result = x / y;
    OUTPUT:return(result); Remember to place the result in the form text box named answer

  4. Open a browser and verify that the file displays properly. Keep this window open until the instructor has had time to verify your work. In order to obtain full credit for the lab your source code must be checked by your grader.