Which house?

Write an app that will tell users which house they are in. It starts like this:

Start

Month must be a number from 1 to 12. Day must be a number from 1 to 31. Show errors if applicable. (You don't have to validate days according to month. For example, month = 2 and day = 31 need not generate an error.)

Error

Use the flag pattern to report all input errors. That is, if both the month and day are wrong, clicking the button will show two error messages.

Show the house, based on the day:

Day House
1 to 11 Slimyin
12 to 17 Huff 'n' Puff
18 to 23 Rave 'n' More
24 to 31 Grip 'n' Chaw

For example:

Output

The multiway if pattern might be useful.

Submit the URL of your solution.

(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)

Referenced in: