-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay-02-Java-Q9
More file actions
66 lines (54 loc) · 1.65 KB
/
Day-02-Java-Q9
File metadata and controls
66 lines (54 loc) · 1.65 KB
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
63
64
65
66
/*Veena wants to learn shape calculation for Square,Rectangle,Circle,Triangle to implements in programming.Could you please help her to how to write the program. - Square formula:a*a - Rectangle formula:l*b - Circle formula:πr^2 - Triangle formula:1/2*(b*h)
Input Format
First input consist of integer for side.
Second and third input consists of integer for Length and breadth.
forth input consist of radius.
Fifth and Sixth input consist of Base and height.
Constraints
No Constraints
Output Format
Execute the area of shape calculation values.
Sample Input 0
2
3
2
3
6
5
Sample Output 0
Area of Square=4
Area of Rectangle=6
Area of Circle=28.27
Area of Triangle=15
Sample Input 1
2
3
4
5
6
7
Sample Output 1
Area of Square=4
Area of Rectangle=12
Area of Circle=78.53
Area of Triangle=21*/
# Answer
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int side = sc.nextInt();
int length = sc.nextInt();
int breadth = sc.nextInt();
int radius = sc.nextInt();
int base = sc.nextInt();
int height = sc.nextInt();
int areaSquare = side * side;
int areaRectangle = length * breadth;
double areaCircle = Math.floor(Math.PI * radius * radius * 100) / 100.0;
int areaTriangle = (base * height) / 2;
System.out.printf("Area of Square=%d\nArea of Rectangle=%d\nArea of Circle=%.2f\nArea of Triangle=%d",
areaSquare, areaRectangle, areaCircle, areaTriangle);
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
}
}