-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearn shape calculation for Square,Rectangle,Circle,Triangle
More file actions
64 lines (50 loc) · 1.34 KB
/
learn shape calculation for Square,Rectangle,Circle,Triangle
File metadata and controls
64 lines (50 loc) · 1.34 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
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
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int l=sc.nextInt();
int b=sc.nextInt();
int r=sc.nextInt();
int base=sc.nextInt();
int h=sc.nextInt();
System.out.println("Area of Square="+(a*a));
System.out.println("Area of Rectangle="+(l*b));
System.out.printf("Area of Circle=%.2f\n",Math.floor((Math.PI*r*r)*100)/100);
System.out.print("Area of Triangle="+(base*h)/2);
}
}