Write a method that returns the area of a circle given the radius.
Use the Math.PI method.
import java.util.Scanner; public class AreaOfCircle { public static double getCircleArea(double radius) { return Math.PI * radius * radius; } public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter radius of circle: "); double radius = in.nextDouble(); System.out.println("Area of circle is " + getCircleArea(radius)); } }
Get Answers For Free
Most questions answered within 1 hours.