Skip to content

Commit 144b71f

Browse files
authored
Create FlowerBed.java
1 parent 1ffd41f commit 144b71f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

FlowerBed.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.Scanner;
2+
3+
/**
4+
* Flower bed is shaped like a circle.
5+
* Calculate its perimeter and area.
6+
* Input the radius from the console, and output obtained results.
7+
*/
8+
public class FlowerBed {
9+
10+
public static void main(String[] args) {
11+
12+
Scanner scanner = new Scanner(System.in);
13+
14+
System.out.print("Input radius of flower bed, meters: ");
15+
double radius = scanner.nextDouble();
16+
17+
double perimeter, area;
18+
19+
perimeter = 2 * Math.PI * radius;
20+
area = Math.PI * Math.pow(radius, 2);
21+
22+
System.out.println("Perimeter of flower bed is " + perimeter + " m");
23+
System.out.println("Area of flower bed is " + area + " m^2");
24+
25+
scanner.close();
26+
}
27+
28+
}

0 commit comments

Comments
 (0)