-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDay26_prob1.java
62 lines (46 loc) · 1.37 KB
/
Day26_prob1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Create a java program:
class Name: Circle
Instance Variable: radus (double type)
Instance Method:
1. area()
2. circumfrence() 3. perimeter()
Write a separate class TestCircle with a main() method and test the Circle class methods.create a circle objects and assign it to reference variables obj
Input Format
radius of circile
Constraints
radius>0
Output Format
prints the result of Area,circumfrence and perimeter of circle.
Sample Input 0
2
Sample Output 0
Area of circle:12.566370614359172
Perimeter of circle:12.566370614359172
Circumference of circle:12.566370614359172
*/
// kirtan jain
import java.io.*;
import java.util.*;
class Circle {
public double radius;
Circle(double radius){
this.radius = radius;
}
public double area(){
return Math.PI*radius*radius;
}
public double circumference() {
return 2*Math.PI*radius;
}
}
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
Circle c1 = new Circle(sc.nextDouble());
System.out.println("Area of circle:"+c1.area());
System.out.println("Perimeter of circle:"+c1.circumference());
System.out.println("Circumference of circle:"+c1.circumference());
}
}