-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathp023rectangle.java
More file actions
83 lines (52 loc) · 1.32 KB
/
p023rectangle.java
File metadata and controls
83 lines (52 loc) · 1.32 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.util.*;
class Rectangle1 {
Scanner sc = new Scanner(System.in);
double width;
double length;
double area;
String color;
void get_length()
{
System.out.print("Length: ");
length = sc.nextDouble();
}
void get_width()
{
System.out.print("Width: ");
width = sc.nextDouble();
}
void get_color()
{
System.out.print("Color: ");
color = sc.next();
}
void find_area()
{
area = length * width;
System.out.println("Area is " + area);
}
}
public class p023rectangle {
public static void main(String[] args) {
Rectangle1 rect1 = new Rectangle1();
System.out.println("First Rectangle - ");
rect1.get_length();
rect1.get_width();
rect1.get_color();
rect1.find_area();
System.out.println();
Rectangle1 rect2 = new Rectangle1();
System.out.println("Second Rectangle - ");
rect2.get_length();
rect2.get_width();
rect2.get_color();
rect2.find_area();
System.out.println();
if (rect1.area == rect2.area && rect1.color == rect2.color) {
System.out.println("Matching");
}
else {
System.out.println("Not matching");
}
}
}