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
33 lines (27 loc) · 765 Bytes
/
Formatter.java
File metadata and controls
33 lines (27 loc) · 765 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
33
public class Formatter {
public static String roundingCostProduct(double izadadd) {
String format = String.format("%.2f", izadadd);
return format;
}
public static String rubleCorrectCase(double price) {
int count = (int) Math.floor(price);
{
double preLastDigit = count % 100 / 10;
if (preLastDigit == 1)
{
return "рублей";
}
switch (count % 10)
{
case 1:
return "рубль";
case 2:
case 3:
case 4:
return "рубля";
default:
return "рублей";
}
}
}
}