If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Programming simple simulations

Problem

The following code simulates the life cycle of a monarch butterfly.
stage ← "egg"
daysAsEgg ← 4
daysAsLarvae ← 12
daysAsPupa ← 12
daysAsAdult ← 36
daysInStage ← 0

REPEAT UNTIL (stage = "death") {
  IF (stage = "egg" AND daysInStage ≥ daysAsEgg) {
    stage ← "larvae"
    daysInStage ← 0
  }
  IF (stage = "larvae" AND daysInStage ≥ daysAsLarvae) {
    stage ← "pupa"
    daysInStage ← 0
  }
  IF (stage = "pupa" AND daysInStage ≥ daysAsPupa) {
    stage ← "adult"
    daysInStage ← 0
  }
  IF (stage = "adult" AND daysInStage ≥ daysAsAdult) {
    stage ← "death"
    daysInStage ← 0
  }
  daysInStage ← daysInStage + 1
  DISPLAY(lifeState)
}
Which details are excluded from this simulation?
👁️Note that there are 2 answers to this question.
Choose 2 answers:
🤔