-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathComputeArea.java
More file actions
44 lines (41 loc) · 1.23 KB
/
ComputeArea.java
File metadata and controls
44 lines (41 loc) · 1.23 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
//Author : Deepansh Dubey.
//Date : 14/09/2021.
import java.io.*;
class ComputeArea
{
int length, base;
float breadth, height;
void area(int length)
{
int area = length*length;
System.out.println("Area of Square = " + area);
}
void area(int length,float breadth)
{
float area = length*breadth;
System.out.println("Area of Rectangle = " + area);
}
void area(int base, int height)
{
float area=(base*height)/2;
System.out.println("Area of Triangle = " + area);
}
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
int l,h,bs;
float b;
System.out.println("Please enter the length.");
l=Integer.parseInt(br.readLine());
System.out.println("Please enter the breadth.");
b=Float.parseFloat(br.readLine());
System.out.println("Please enter the height.");
h=Integer.parseInt(br.readLine());
System.out.println("Please enter the base.");
bs=Integer.parseInt(br.readLine());
ComputeArea ob=new ComputeArea();
ob.area(l,l);
ob.area(l,b);
ob.area(bs,h);
}
}