Write a program to compute the price of renting an animal from Ulma's Ungulates. You can rent either a llama, or a camel. The price depends on:
- Which animal you choose.
- How far you want to ride the aminal.
- Whether you want to rent a saddle as well.
The worksheet starts like this:
The user fills in the three fields above the Run button, and clicks Run. Here's some output:
Here's another sample:
Validate all the input, using the following rules:
- The animal input must be either L or C. Case doesn't matter. Use trim() to remove unwanted spaces.
- The number of miles must be numeric, and between 3 and 50 inclusive.
- Saddle is either Y or N. Case doesn't matter. Use trim() to remove unwanted spaces.
If there are any input errors, show a message, and end the program. For example:
Output the full name of the animal, the warning, and the cost.
- Llamas cost $20 per mile.
- Llama saddles rent for $120.
- Camels cost $12 per mile.
- Camel saddles rent for $180.
The usual coding standards apply.
(If you were logged in as a student, you could submit an exercise solution, and get some feedback.)
Keywords: