-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ04002_KhaiBaoLopHinhChuNhat.java
76 lines (60 loc) · 1.63 KB
/
J04002_KhaiBaoLopHinhChuNhat.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
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
import java.io.*;
import java.math.*;
import java.util.*;
class Rectange {
private double width, height;
private String color;
public Rectange() {
this.width = 1;
this.height = 1;
}
public Rectange(double w, double h, String c) {
this.width = w;
this.height = h;
this.color = c;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public double getHeight() {
return height;
}
public void setHeight(double height) {
this.height = height;
}
public String getColor() {
String ch = color;
ch = ch.toLowerCase();
char x = ch.charAt(0);
x = (char) (x - 32);
ch = x + ch.substring(1);
color = ch;
return color;
}
public void setColor(String color) {
this.color = color;
}
public double findArea() {
return width * height;
}
public double findPerimeter() {
return 2 * (width + height);
}
public boolean check() {
return (width > 0 && height > 0) ? true : false;
}
}
public class J04002_KhaiBaoLopHinhChuNhat {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Rectange a = new Rectange(sc.nextDouble(), sc.nextDouble(), sc.next());
if (a.check()) {
System.out.printf("%.0f %.0f %s\n", a.findPerimeter(), a.findArea(), a.getColor());
} else {
System.out.println("INVALID");
}
}
}