#C5559. Animal Food Consumption Calculator
Animal Food Consumption Calculator
Animal Food Consumption Calculator
Given the number of days an animal has been in your care and its type, compute the total amount of food consumed by that animal over the given period.
The animal types are limited to:
- elephant: Consumes 50 units of food per day.
- lion: Consumes 3 units on the first day and the consumption increases by 1.5 units on each subsequent day. Hence, the total consumption is given by \(3 \times days + 1.5 \times \frac{days \times (days-1)}{2}\).
- monkey: Consumes 0.3 units on the first day and increases by 0.1 unit on each subsequent day. Its total consumption is \(0.3 \times days + 0.1 \times \frac{days \times (days-1)}{2}\).
If an invalid animal type is provided, the program should report an error.
inputFormat
The input consists of two lines. The first line contains an integer representing the number of days. The second line contains a string representing the animal type ("elephant", "lion", or "monkey").
outputFormat
Output a single floating-point number rounded to one decimal place representing the total amount of food consumed over the given number of days. If the animal type is invalid, output an error message.## sample
1
elephant
50.0
</p>