importjava.util.Scanner;classGD{publicstaticvoidmain(Stringargs[]){floatr;Scannersc=newScanner(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
godarda@gd:~$ javac GD.java godarda@gd:~$ java GD
———————————————————————————————————————————
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
———————————————————————————————————————————
godarda@gd:~$
Dear User, Thank you for visitng GoDarda. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.