-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.java
More file actions
24 lines (24 loc) · 928 Bytes
/
Circle.java
File metadata and controls
24 lines (24 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// to find the perimeter and area of a circle given a value of radius.
// You should use Math.PI constant in your program. If radius is zero or less than zero then print " please enter non zero positive number ".
import java.util.Scanner;
public class Circle
{
public static void main(String[] args)
{
try (Scanner s = new Scanner(System.in)) {
System.out.print("Enter the Radius of the circle : ");
double radius= s.nextDouble();
double perimeter;
double area;
if(radius!=0 && radius>=0)
{
perimeter = 2*Math.PI*radius;
area = Math.PI * radius* radius;
System.out.println("Permetr of Circlr : "+perimeter);
System.out.print("Area of Circlr : "+area);
}
else
System.out.println("please enter non zero positive number");
}
}
}