Java program to calculate the area of a circle
KW.java
import java.util.Scanner;
class KW
{
    public static void main(String args[])
    {
        float r;
        Scanner sc=new Scanner(System.in);
        System.out.println("———————————————————————————————————————————");
        System.out.println("Program to calculate the area of circle ");
        System.out.println("———————————————————————————————————————————");
        System.out.print("Enter the radius of circle ");
        r=sc.nextFloat();
        System.out.println("Area of circle is "+(3.14*r*r));
        System.out.println("Circumference of circle is "+(2*3.14*r));
        System.out.println("———————————————————————————————————————————");
    }
}
Output
kodingwindow@kw:~$ javac KW.java
kodingwindow@kw:~$ java KW ——————————————————————————————————————————— Program to calculate the area of circle ——————————————————————————————————————————— Enter the radius of circle 10 Area of circle is 314.0 Circumference of circle is 62.800000000000004 ——————————————————————————————————————————— kodingwindow@kw:~$
Advertisement