Challenge
No
Zilo is a self-proclaimed Zen master. Goat Zen is nothing like human Zen. Goat Zen is about purity-of-hide. The more tattoos, the better. Why? Zilo says it came to him in a divine dream.
Write a program to compute a goat's Zen rating, based on the number of tattoos they have.
Tattoos | Rating |
---|---|
0 | 0 |
More than 0, less than 4 | 1 |
4 or more, less than 8 | 2 |
8 or more, less than 14 | 3 |
14 or more | 4 |
There's one exception. If the goat has a tattoo on its tongue, its zen rating is 5. No need to ask any other questions.
Validation rules:
- Tongue tattooness must be Y or N, although allow spaces and upper/lowercase.
- Number of tattoos: Integer, from 0 to 100.
Here's some I/O:
- Does the goat have a tongue tattoo? (Y=yes, N=no)? y
- Zen rating: 5
More:
- Does the goat have a tongue tattoo? (Y=yes, N=no)? n
- How many tattoos? 7
- Zen rating: 2
Even more.
- Does the goat have a tongue tattoo? (Y=yes, N=no)? asfd
- Please enter Y or N.
- Does the goat have a tongue tattoo? (Y=yes, N=no)? ff
- Please enter Y or N.
- Does the goat have a tongue tattoo? (Y=yes, N=no)? y
- Zen rating: 5
Yet more.
- Does the goat have a tongue tattoo? (Y=yes, N=no)? n
- How many tattoos? asd
- Sorry, you must enter a whole number.
- How many tattoos? 2.3
- Sorry, you must enter a whole number.
- How many tattoos? -2
- Sorry, please enter a number zero or more, and 100 or less.
- How many tattoos? 434
- Sorry, please enter a number zero or more, and 100 or less.
- How many tattoos? 2
- Zen rating: 1
Upload a zip of your project folder. The usual coding standards apply.
If you were logged in as a student, you could submit a solution to this exercise.
Where referenced