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
25 lines (20 loc) · 1.32 KB
/
Main.java
File metadata and controls
25 lines (20 loc) · 1.32 KB
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
import java.util.Locale;
public class Main {
public static void main(String[] args) {
Persons persons = new Persons(); // Создаём новый объект класса Persons
persons.read(); // Вызываем метод read класса Persons.
Calculator calculator = new Calculator(); // Создаём новый объект класса Persons
calculator.calculate(); // Вызываем метод calculate класса Calculator.
for (Product product : calculator.products) { // Из объекта calculator класса Calсulator в вытаскиваем список продуктов.
System.out.println(String.format(Locale.US, "Добавленные товары: %s - %.2f Руб.", product.name, product.cost)); // Для каждого продукта из списка печатаем его имя и цену.
}
float averageCheck = (float) (calculator.total / persons.count); // Подсчитываем средний чек
String rub = "ру";
if (averageCheck < 2 && averageCheck >= 1) {
rub = rub + "бль";
} else {
rub = rub + "бля";
}
System.out.println(String.format(Locale.US, "%.2f %s с каждого гостя.", averageCheck, rub));
}
}