Java Arithmetic Operator calculate circle area

Question

We would like to calculate the circle area.

Code structure you can use:

public class Main {
  public static void main(String[] args) {
    double radius; // Declare radius
    double area; // Declare area

    // Assign a radius
    radius = 20; // New value is radius
    /*from  www .j  a v a2s  .c om*/
    
    //your code here
  }
}



public class Main {
  public static void main(String[] args) {
    double radius; // Declare radius
    double area; // Declare area

    // Assign a radius
    radius = 20; // New value is radius

    // Compute area
    area = radius * radius * 3.14159;

    // Display results
    System.out.println("The area for the circle of radius " +
      radius + " is " + area);
  }
}



PreviousNext

Related