To calculate Area of Circle in java program

To calculate Area of Circle in java program

Area of Circle in java

The following Java program to print the area of a circle has been written in five simple different ways, static method, using constructor, Interface, inheritance with sample outputs for each program.

Source Code

import java.io.*;
import java.util.*;
class Area
{
public static void main(String []args)
{
Scanner ob=new Scanner(System.in);
int l,h,r;
System.out.println(“enter value l,h,r”);
r=ob.nextInt();
int c=(double)3.14*r*r;
System.out.println(“area of circle:”+c);

}
}

Leave a Comment

Your email address will not be published. Required fields are marked *