Answer:
The answer is "Option e".
Explanation:
In this question we calculating the volume of a cylinder, that's formula is:
[tex]\boxed{\text{Volume}= \pi \times r^2 \times h}[/tex]
In the above, we use π that's value is 3.14 or [tex]\frac{22}{7}[/tex] and "r and h" is input by the user. In the given choices all were correct it calculates the volume, that can be defined as follows:
- In choice 1, The double variable "baseArea" is declared, which first calculates [tex]\pi \cdot r^2[/tex] value then multiply the h value and store it into the "volume" variable.
- In choice 2, The double variable "volume" is declared, which first calculates [tex]\pi \cdot r^2[/tex] value then multiply the h value and store it into the "volume" variable.
- In choice 2, The double variable "volume" is declared, which directly calculates the volume value by the above-given formula.