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
19 lines (18 loc) · 811 Bytes
/
Formatter.java
File metadata and controls
19 lines (18 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class Formatter {
public String rightFormat(double floatTotal) {
double total = (Math.floor(floatTotal)) % 100;
double t = total % 10;
if (total == 0) {
String rightTotal = String.format("%.2f", floatTotal) + " рублей";
} else if (total > 10 & total <20) {
return String.format("%.2f", floatTotal) + " рублей";
} else if (t == 1) {
return String.format("%.2f", floatTotal) + " рубль";
} else if (t > 1 & t < 5) {
return String.format("%.2f", floatTotal) + " рубля";
} else {
return String.format("%.2f", floatTotal) + " рублей";
}
return null;
}
}