COP2500 Assignment 3

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.) Complete the lab during the time provided or email your results to your lab instructors.
3.) Demonstrate youir program(s) to your lab instructor.

Introduction: The goal of this assignment is to give you experience working with IF-THEN-ELSE blocks. IF-THEN-ELSE blocks let you choose what parts of your code execute based on input data.

Procedures:
PART 1:

  1. Use a text editor to complete your assignment.
  2. Using your text editor create a new document named "cop2500lab3.html". Do not close out the window until after the lab instructor has had time to verify your work.
  3. Convert the following two algorithms into JavaScript code within your HTML document. Your final web page should display the algorithm title, the input and the output. The specific format you use to display the results is up to you, but it should be clear what the input and output means (in other words, don't just list rows of numbers without words or labels describing them). The first algorithm, Max3(x, y, z), calculates the maximum of three numbers. The second algorithm, LetterGrade(x), computes a letter grade from a numeric grade.

    Here is a brief list of helpful HTML tags and JavaScript functions.

    Max3(x, y, z): Finding the largest number.
    SectionPseudocodeComments
    INPUT:Number x, y, z; We require three numbers
    OTHER VARIABLES:Number max;
    INITIALIZATION: Assume x, y, and z
    are given to us.
    COMPUTATION: IF (x > y) THEN
    max = x;
    ELSE
    max = y;
    ENDIF

    IF (z > max) THEN
    max = z;
    ENDIF
    Convince yourself these
    comparisons provide the
    correct result.
    OUTPUT:return(max); Remember to format your results
    in a sensible way.

    LetterGrade(x): Computes a letter grade.
    SectionPseudocodeComments
    INPUT: Integer NumGrade; This is the numeric grade,
    0 - 100 percent.
    OTHER VARIABLES:Char AlphGrade; This is where we will
    store the letter grade.
    INITIALIZATION: Assume NumGrade is given.
    COMPUTATION:
     IF (NumGrade > 89) THEN 
       AlphGrade = "A"; 
     ELSE 
       IF (NumGrade > 79) THEN 
         AlphGrade = "B"; 
       ELSE 
         IF (NumGrade > 69) THEN
           AlphGrade = "C"; 
         ELSE 
           IF (NumGrade > 59) THEN 
             AlphGrade = "D"; 
           ELSE 
             AlphaGrade = "F"; 
           ENDIF 
         ENDIF
       ENDIF         
     ENDIF 
    Note the use of the
    "nested" IF-THEN-ELSE
    structures. It may be
    easier to do one at
    a time, then view it.
    OUTPUT: return (AlphGrade);



  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 you need to email your source code to your grader, and you need to show him that it is working in the lab.