? Week 5 Day 4 Challenge — Roller Coaster Height Checker
CodeX Academy · Level 1 — App Lab · Lesson 9

Roller Coaster Height Checker

A model example only — not tonight's graded project. Same input → variable → decision → output trace as class, on number ranges instead of words, for inspiration before you build your own fresh app.

1. Build this in Design Mode first

STEP 1

Create these elements on screen1 with these exact IDs and starting text.

TypeIDText
LabelpromptLabelEnter your height in inches:
TextInputheightInput(leave blank)
ButtoncheckBtnCheck Rides
LabelresultLabelResult: --

2. Switch to Code Mode

STEP 2

Copy this starter code into Code Mode and fill in the marked STEP.

onEvent("checkBtn", "click", function() {
  var height = getNumber("heightInput");

  // STEP: write an if / else if / else chain and set resultLabel:
  //   below 36   -> "Result: Too short for any ride."
  //   below 48    -> "Result: Kiddie rides only."
  //   below 60    -> "Result: Most rides, with an adult."
  //   otherwise   -> "Result: All rides allowed."

});

3. Check yourself — predict before you test

STEP 3
InputWhat it should test
30clearly too short
36exactly the first cutoff
40clearly kiddie only
48exactly the second cutoff
55clearly most rides
60exactly the third cutoff
72clearly all rides

If 36, 48, or 60 land on the wrong side of their cutoff, that's a boundary bug — recheck the comparison operator on that one line first.

Try it for real before checking the answer key.

Answer key
onEvent("checkBtn", "click", function() {
  var height = getNumber("heightInput");

  if (height < 36) {
    setText("resultLabel", "Result: Too short for any ride.");
  } else if (height < 48) {
    setText("resultLabel", "Result: Kiddie rides only.");
  } else if (height < 60) {
    setText("resultLabel", "Result: Most rides, with an adult.");
  } else {
    setText("resultLabel", "Result: All rides allowed.");
  }
});