forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormatter.java
More file actions
30 lines (28 loc) · 744 Bytes
/
Formatter.java
File metadata and controls
30 lines (28 loc) · 744 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
public class Formatter {
final private static String[] strRub = {
" рубль",
" рубля",
" рублей"
};
public static String getEndWord(double productPrice) {
int intPrice = (int) productPrice;
if (intPrice >= 5 && intPrice <= 19) {
return strRub[2];
} else {
switch (intPrice % 10) {
case 2:
case 3:
case 4:
return strRub[1];
case 0:
case 5:
case 6:
case 7:
case 8:
case 9:
return strRub[2];
}
}
return strRub[0];
}
}