-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDifferareas.java
More file actions
53 lines (53 loc) · 1.07 KB
/
Differareas.java
File metadata and controls
53 lines (53 loc) · 1.07 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
import java.util.Scanner;
class Qareas
{
int b,h,s,l,h1,h2;
Qareas(int b,int h)
{
this.b=b;
this.h=h;
}
Qareas(int s)
{
this.s=s;
}
Qareas(int h,int l,int h2)//i used h2 only to show difference in no.of parameters
{
this.h=h;
this.l=l;
}
public void show()
{
System.out.println("area of trianle is"+(b*h)/2);
}
public void show1()
{
System.out.println("area of square is"+s*s);
}
public void show2()
{
System.out.println("area of rectangle is"+l*h);
}
}
public class Differareas
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.println("enter breadth and height");
int height=s.nextInt();
int breadth=s.nextInt();
Qareas b1=new Qareas(height,breadth);
b1.show();
System.out.println("enter side of square");
int side=s.nextInt();
Qareas b2=new Qareas(side);
b2.show1();
System.out.println("enter length and height");
int length=s.nextInt();
int height1=s.nextInt();
int h2=0;
Qareas b3=new Qareas(length,height1,h2);
b3.show2();
}
}