forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
29 lines (22 loc) · 940 Bytes
/
Main.java
File metadata and controls
29 lines (22 loc) · 940 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
public class Main {
static String end = "Завершить"; // проверка для завершения ввода продуктов
public static void main(String[] args) {
People.howPeople();
Product.calculate();
// Вывод результата
double costPerson = Product.cost / People.countPeople;
double checkCostPerson = Math.floor(costPerson);
System.out.println("Добавленные товары:\n" + Product.name);
System.out.printf("%.2f", costPerson);
rublesName(checkCostPerson);
}
public static void rublesName(double cost) {
if (cost % 10 == 1 && cost != 11 && cost % 100 != 11) {
System.out.println(" рубль.");
} else if (cost % 10 >= 2 && cost % 10 <= 4) {
System.out.println(" рубля.");
} else {
System.out.println(" рублей.");
}
}
}