forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalc.java
More file actions
34 lines (23 loc) · 992 Bytes
/
Calc.java
File metadata and controls
34 lines (23 loc) · 992 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
29
30
31
32
public class Calc {
public static void getRubl(double rubl) {
int endRub = (int) Math.floor(rubl);
String endPlat = String.format("%.2f", rubl);
if ((endRub % 100 / 10) == 1) {
System.out.println("Каждый человек должен заплатить по " + endPlat + " рублей");
return;
}
switch (endRub % 10) {
case 1:
System.out.println("Каждый человек должен заплатить по " + endPlat + " рублю");
return;
case 2:
case 3:
case 4:
System.out.println("Каждый человек должен заплатить по " + endPlat + " рубля");
return;
default:
System.out.println("Каждый человек должен заплатить по " + endPlat + " рублей");
return;
}
}
}