Which of the following code displays the area of a circle if the radius is positive. a. if (radius != 0) System.out.println(radi
us * radius * 3.14159); b. if (radius >= 0) System.out.println(radius * radius * 3.14159); c. if (radius <= 0) System.out.println(radius * radius * 3.14159); d. if (radius > 0) System.out.println(radius * radius * 3.14159);
d. if (radius > 0) System.out.println(radius * radius * 3.14159);
Explanation:
The positive values are those values that are greater than 0(zero).0 is considered to be nonnegative number it is neither positive nor negative and for a zero radius the area will be 0.As we know the are of the circle is π*radius*radius, and π is 3.14159.So the correct answer matching to this condition is option d.
Which checks if the radius is greater than 0 then find the radius and print it.