1import java.util.Scanner;
2public class CalculateAreaOfCircle
3{
4 public static void main(String[] args)
5 {
6 double radius;
7 double pi = 3.1415, area;
8 Scanner sc = new Scanner(System.in);
9 System.out.println("Please enter radius of circle: ");
10 radius = sc.nextDouble();
11 area = pi * radius * radius;
12 System.out.println("Area of circle: " + area);
13 sc.close();
14 }
15}
1import java.util.Scanner;
2public class AreaOfCircle {
3 public static void main(String args[]){
4 int radius;
5 double area;
6 Scanner sc = new Scanner(System.in);
7 System.out.println("Enter the radius of the circle ::");
8 radius = sc.nextInt();
9 area = (radius*radius)*Math.PI;
10 System.out.println("Area of the circle is ::"+area);
11 }
12}
1public class scratch {
2 public static void main(String[] args) {
3 JFrame window = new JFrame();
4 window.setTitle("Christmas Tree");
5 window.setSize(700, 600);
6 window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
7 window.setVisible(true);
8 DrawingComponent DC = new DrawingComponent();
9 window.add(DC);
10 }
11}
12class DrawingComponent extends JComponent{
13 public void paint(Graphics graph0){
14 Graphics2D graph = (Graphics2D) graph0;
15 Ellipse2D.Double circle = new Ellipse.Double(5, 5, 25, 25);
16 graph.fill(circle);
17 }
18}
1import java.util.Scanner;
2
3public class Main {
4
5 public static void main(String[] args) {
6
7 final float PI = 3.14f;
8 Scanner scanner = new Scanner(System.in);
9
10 System.out.print("Enter radius of circle: ");
11 int radius = scanner.nextInt();
12
13 double areaOfCircle = PI * Math.pow(radius,2);
14
15 System.out.printf(" Area of circle of circle is %.2f ",areaOfCircle);
16 }
17}
18
1import java.util.Scanner;
2
3public class Main {
4 public static void main(String[] args){
5 double R,A;
6 Scanner sc = new Scanner(System.in);
7 R = sc.nextDouble();
8 A = 3.14159 * R * R;
9 System.out.printf("A=%.4f\n", A);
10 }
11}