Cthulhu sponsors goat races every month. The course varies in length, and whether there are hurdles or not. Before each race, Cthulhu feeds the goats, so they have the energy they'll need. Write a program to work out the number of kilocalories needed for a race.
You can download a start worksheet. It looks like this:
The user types:
- The number of goats (must be a number more than zero)
- The course length (must be a number at least 10)
- Whether there are hurdles (must be y or n, allow upper- or lowercase, and extra spaces)
Validate the data, showing all appropriate error messages. For example:
Make sure error messages and output are cleared each time the program runs.
Some sample output:
Kilocalories is goats times length times 100 divided by 1,000. If there are hurdles, multiply kilocalories times two.
If more than 100 kilocalories are needed, Cthulhu wants to bring in Euphonites, his goat nutritionist. Show a message to that effect:
Upload your workbook. The usual coding standards apply.