-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQB 814.java
More file actions
45 lines (38 loc) · 866 Bytes
/
QB 814.java
File metadata and controls
45 lines (38 loc) · 866 Bytes
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
// //QB 814
import java.util.Scanner;
class figure {
double a;
double b;
figure() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter A");
a = sc.nextInt();
System.out.println("Enter B");
b = sc.nextInt();
// return 0;
}
double area() {
return 0;
}
}
class rectangle extends figure {
double area() {
return a * b;
}
}
class triangle extends figure {
double area() {
return 0.5 * a * b;
}
}
class main {
public static void main(String[] args) {
System.out.println("For Area of Triangle");
triangle m1 = new triangle();
double x = m1.area();
System.out.println("For Area of Rectangle" + x);
rectangle m2 = new rectangle();
double y = m2.area();
System.out.println(y);
}
}