-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtri.java
28 lines (24 loc) · 854 Bytes
/
tri.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
//write a java program to calculate the area of rectangle,square & triangle
import java.util.Scanner;
public class tri {
public static void main(String[] args) {
Scanner ab = new Scanner(System.in);
float l,b,s,c,h,x,y,z;
System.out.println("enter the length: ");
l = ab.nextInt();
System.out.println("enter the breadth: ");
b = ab.nextInt();
x = l * b;
System.out.println("Area of rectangle: "+x);
System.out.println("enter the side: ");
s = ab.nextInt();
y = s * s;
System.out.println("Area of square: "+y);
System.out.println("enter the base: ");
c = ab.nextInt();
System.out.println("enter the height: ");
h = ab.nextInt();
z = (c*h)/2;
System.out.println("Area of triangle: "+z);
}
}