-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun5.java
More file actions
23 lines (19 loc) · 569 Bytes
/
Fun5.java
File metadata and controls
23 lines (19 loc) · 569 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package fun;
public class Fun5 {
public static void main(String[] args) {
rectPS(-2, 8, 6, -2);
}
// qarama-qarshi uchlari koordinatalari berilgan
// yuza va perimeter topilsin
// a = |x1-x2|; b = |y1-y2|
// s = a*b
// p = 2*(a+b)
public static void rectPS(double x1, double y1, double x2, double y2) {
double a = Math.abs(x1 - x2);
double b = Math.abs(y1 - y2);
double s = a * b;
double p = 2 * (a + b);
System.out.println("s = " + s);
System.out.println("p = " + p);
}
}