- Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFun4.java
28 lines (25 loc) · 777 Bytes
/
Fun4.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
packagefunsimple;
publicclassFun4 {
publicstaticvoidmain(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;
*/
publicstaticvoidtriangle(doublea) {
if (a > 0) {
doublep = 3 * a; // perimeter
doubles = 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.");
}
}
}