forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculation.java
More file actions
28 lines (24 loc) · 784 Bytes
/
Calculation.java
File metadata and controls
28 lines (24 loc) · 784 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
public class Calculation {
public static String everyPeoplePrice(double price ) {
String readySum = "";
double priceNoDouble = Math.floor(price);
int priceName = (int) (priceNoDouble % 10);
int priceNameUnusial = (int) (priceNoDouble % 100);
if (priceName == 1) {
readySum = "рубль.";
}
if (priceName>=2 && priceName<=4) {
readySum = "рубля.";
}
if (priceName>=5 && priceName<=9) {
readySum = "рублей.";
}
if(priceName>=10 && priceName<=20) {
readySum = "рублей.";
}
if(priceNameUnusial>=10 && priceNameUnusial<=20) {
readySum = "рублей.";
}
return readySum;
}
}