Write a program to find area of circle by user input in java

Share Your Love

Hellow guys, welcom to Lingarajtechhub.Today we are going to discuss find area of circle by user input in java.


package com.operators.java;
import java.util.Scanner;
public class Area_of_circle {
	public static void main(String[] args) {
		double area,radius;
		Scanner sc =new Scanner (System.in);
		System.out.println("Enter the radius of circle :");
		double pi = 3.14;
		area = pi* radius* radius;
		System.out.println("Area of the circle :"+area);


package com.Operators.Java;

  •  It is a java package  which is a collection of classes and this package is created in a java project(Homework_operator) .
  • Here com.operators.java is the  name of our package.


import java.util.Scanner;

  • Scanner is a class in java
  • . util  package used for obtaining the input of the primitive types like int, double, etc. and strings .


public class Area_of_circle

  • Here “Area_of_circle” is defined as a class which is a template used to create objects ,& to define object ,data type and method.
  • It is defined as public because it can be accessed anywhere.
  • It is the entry point to the application.


public static void main(String[] args){

  • This is the main () method of our java program .
  • Every java program must contain the main() method .
  • Public : It is the access modifier of the main function which must be public so that the JRE can access and execute this method.
    • If a method is not public then access is restricted and its showing error.
  • Static : Static is a keyword in which the main method has to be static in which JVM can load the class into memory and call the main method without creating an instance .
  •  Void : It means no return types.
  •  Main() :  It is a function.
  •  String [] args :String means collection of characters
    •      String[] args represents a collection of Strings ,that are separated by a space and can be typed into the program on the terminal directly.


double radius ,area ;

  • Here we Declare 2 variable radius ,area  which is double type and double is a local variable.


  •  Scanner Sc = new Scanner(System.in);
  • Here scanner is a class and Sc is the instance of the object which is the new Scanner. System.in is an argument.



  • radius”  is a variable that we take and sc is our instance name which is created for an object and nextDouble() is a method of a Scanner object that reads in a string of digits or char and converts them into an double type.


System.out.println(” Area of the circle “+area);

  •   It means System is a class name and out is an instance of the System println is to print a new line and “+” means cocardinate  .

Share Your Love
Avatar photo

Myself Sonalin Shaoo. I am quite happy to contribute here some java programming content and my friends Lipsa Mohanty ,Sushil Puhan, Aswin Kumar Nayak also help me to contribute their Opinion on this .

Articles: 40

Newsletter Updates

Enter your email address below to subscribe to our newsletter