Actions Problems

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14

Write an Action

Bring together all the parts of programming actions to create a zombie mood meter. This action will take an integer value representing the number of hours since the zombie has eaten. Then, it will return text describing the zombie's mood. The action will have a signature like the following: action ZombieMood(integer hoursSinceEaten) returns text.

Inside the action scope, if the number of hours since eating is less than three, return the text "Calm". If the number of hours is three to six hours, return the text "Hungry". If it's been more than six hours, return "Raging".

Once you have written the action, call the action three times in Main with the hours set to 2, 6, and 9. Then, output your zombie's mood results. A working program will have an action defined, and the output will match the following program output.

Zombie Mood: Calm
Zombie Mood: Hungry
Zombie Mood: Raging

Coding:

Blocks

PreviousNext