Find out the area of circle take user input in java Programming .
Find out the
area of circle take user input in java
Programming .
Theory : First we have to take a variable r in data
type int or float as your wish .Now you have to set a veriable in data type float (pi=3.1416), and you take
a float type variable name area .
Now you have to take input from user by using
(Scanner input =new Scanner (System.in);
r=input.nextInt();)
After doing this things you hae to apply the theory of
area of circle (area =pi*r*r). after that print the area veriable.
Souce Code:
package basicjava;
import java.util.Scanner;
public class AreaOCircle {
public
static void main(String[] args) {
int r;
float
area,pi=(float) 3.1416;
Scanner
input =new Scanner (System.in);
System.out.println("Enter the value of r:");
r=input.nextInt();
area=pi*r*r;
System.out.println("Area of cicle is = "+area);
}
}
Output :
Enter the value of r:5
Area of cicle is = 78.53999
No comments