Loading...
Loading...
Loading...
A pizza shop lists each pizza by its radius in centimetres and wants the area (how much pizza) and the circumference (how much crust).
Write a class Circle with a field radius and methods double area() and double circumference() that use Math.PI. Create one Circle per pizza.
Example
Input
3 1 7 10
Output
3.14 6.28 153.94 43.98 314.16 62.83
Radius 1 gives π and 2π.
Try the problem first. Open one hint at a time.
Area is π × r × r and circumference is 2 × π × r.
An int read from the input can be stored in a double field directly.
Print with printf("%.2f %.2f%n", ...).
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor