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 your 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:
| Section | Pseudocode | Comments | |
|---|---|---|---|
| INPUT: | var x, y, z; | We require three numbers | |
| OTHER VARIABLES: | var max; | ||
| INITIALIZATION: | x = 34, y = 10, |
||
| 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: | display max using document.write() or some other output function |
Remember to format your results in a sensible way. |
LetterGrade(x): Computes a letter grade.
| Section | Pseudocode | Comments | |
|---|---|---|---|
| INPUT: | var NumGrade; | This is the numeric grade,
|
|
| OTHER VARIABLES: | var AlphGrade; | This is where we will store the letter grade. | |
| INITIALIZATION: | 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
AlphGrade = "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: | display AlphGrade using document.write() or some other output function |