-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFun4.java
More file actions
28 lines (25 loc) · 771 Bytes
/
Fun4.java
File metadata and controls
28 lines (25 loc) · 771 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
package fun;
public class Fun4 {
public static void main(String[] args) {
triangle(4); // test1 a = 4 -> p=12; s=4*sqrt(3);
triangle(3); // test1 a = 4 -> p=12; s=4*sqrt(3);
triangle(-3); // test1 a = 4 -> p=12; s=4*sqrt(3);
}
/**
* a - t.tomonli uchburchak tomoni
* p = a+a+a = 3*a;
* s = a*a*sqrt(3)/4;
*/
public static void triangle(double a) {
if (a > 0) {
double p = 3 * a; // perimeter
double s = a * a * Math.sqrt(3) / 4;
// f-haqiqiy
// d-butun son
// s-string
System.out.printf("P = %.2f, S = %.2f\n", p, s);
} else {
System.out.println("Uchburchak tomoni xato kiritildi.");
}
}
}