The Classroom Water Budget
Follow instruction sequences to guide the character to the goal.
- Web browser (Chrome, Edge, Firefox)
- Internet connection
- Scratch 3.0 online editor
🔧 Build Your Classroom Water Budget
when [green flag] clicked
set [daily_budget v] to [200]
set [total_consumed v] to [0]
set [water_remaining v] to (daily_budget)
say [Classroom Water Station Ready: 200L Available]
when [space v] key pressed // Pupil drinks 1 cup (0.5L)
change [total_consumed v] by (0.5)
set [water_remaining v] to ((daily_budget) - (total_consumed))
say (join [Cup dispensed! Remaining: ] (join (water_remaining) [ Liters]))
if <(water_remaining) <= [30]> then
say [CAUTION: Water budget low! Drink mindfully.]
play sound [Alert v]
end
Calculating remaining water dynamically prevents over-consumption and tank depletion.
⚗️ Test your model
| Test Condition / Action | Expected Result |
|---|---|
| Dispense 1 cup | total_consumed = 0.5L, water_remaining = 199.5L |
| Dispense 10 cups | total_consumed = 5.0L, water_remaining = 195.0L |
| Water reaches 30L | Conservation warning activates; alert chime sounds |
Calculate the average hourly consumption rate and predict what time the tank will run dry!
📖 Our Story & Concepts
During dry season, many schools receive a fixed delivery of clean water each morning. If students drink without tracking, the tank empties before afternoon lessons, leaving everyone thirsty during sports.
Resource budgeting in computer science involves comparing continuous consumption against fixed quotas. By tracking rates and thresholds, digital systems help communities manage electricity, fuel, water, and internet data sustainably.
</> Full Annotated Code Walkthrough
// Complete Water Budget with Hourly Pacing Monitor
when [green flag] clicked
set [daily_budget v] to [200]
set [total_consumed v] to [0]
set [water_remaining v] to [200]
set [cup_count v] to [0]
when [space v] key pressed
if <(water_remaining) >= [0.5]> then
change [cup_count v] by (1)
change [total_consumed v] by (0.5)
set [water_remaining v] to ((daily_budget) - (total_consumed))
play sound [Drip v]
say (join [Cups: ] (join (cup_count) (join [ | Left: ] (join (water_remaining) [L]))))
else
say [TANK EMPTY! Please refill dispenser.]
play sound [Buzzer v]
end
Calculating remaining water dynamically prevents over-consumption and tank depletion.
▷ Expected Results & Troubleshooting
| Test Condition / Action | Expected Result |
|---|---|
| Dispense 1 cup | total_consumed = 0.5L, water_remaining = 199.5L |
| Dispense 10 cups | total_consumed = 5.0L, water_remaining = 195.0L |
| Water reaches 30L | Conservation warning activates; alert chime sounds |
⚑ Extension Challenges & Blueprints
- Level 1: Add a Jerrycan button (J key) that dispenses 20 Liters at once.
- Level 2: Display a visual progress bar that shrinks as water is consumed.
- Level 3: Add a refill key with password protection that resets the budget to 200L.