Java examples for Language Basics:Math
Circle Area Calculator with Math function
import java.util.Scanner; public class CircleAreaApp { static Scanner sc = new Scanner(System.in); public static void main(String[] args) {//from w w w. j ava 2 s . co m System.out.println("Welcome to the circle area calculator."); System.out.print("Enter the radius of your circle: "); double r = sc.nextDouble(); double area = Math.PI * (r * r); System.out.println("The area is " + area); } }