Challenge
No
Ulma rents out animals for people to ride. Write a program to compute the price of renting an animal. You can rent either a llama or a camel.
The price depends on:
- Which animal you choose.
- Whether you want to rent a saddle as well.
Ask the user to choose an animal, and saddle choice. Validate all the input, using the following rules:
- The animal input must be either L or C. Case doesn't matter. There can be extra spaces, and the program will still work.
- Saddle is either Y or N. Case doesn't matter. There can be extra spaces, and the program will still work.
Keep asking until the user enters valid data. (See I/O below.)
When the data is OK, output the full name of the animal (camel or llama), a warning, and the price.
The warning is "Spits" for llamas, and "Stinks" for camels.
- Llama rent for $80.
- Camels rent for $95.
- Saddles rent for $30.
Here's some I/O.
- Animal (C=Camel, L=Llama)? cat
- Please enter C or L.
- Animal (C=Camel, L=Llama)? l
- Saddle (Y=yes, N=no)? Maybe
- Please enter Y or N.
- Saddle (Y=yes, N=no)? N
- Ulma's Ungulates
- ------ ---------
- Animal: Llama
- Warning: Spits!
- Saddle: No
- ----------------
- Price $: 80
Some more I/O:
- Animal (C=Camel, L=Llama)? humpy one
- Please enter C or L.
- Animal (C=Camel, L=Llama)? c
- Saddle (Y=yes, N=no)? y
- Ulma's Ungulates
- ------ ---------
- Animal: Camel
- Warning: Stinks!
- Saddle: Yes
- ----------------
- Price: $ 125
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