forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInput.java
More file actions
34 lines (29 loc) · 1.29 KB
/
Input.java
File metadata and controls
34 lines (29 loc) · 1.29 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
26
27
28
29
30
31
32
33
34
import java.util.Scanner;
public class Input {
private final Scanner scanner = new Scanner(System.in);
public void quantityOfPeople() {
Calculated calculated = new Calculated();
while (true) {
System.out.println("На скольких человек необходимо разделить счёт?");
if (scanner.hasNextInt()) {
int quantity = scanner.nextInt();
if (quantity <= 1) {
System.out.println("Количество людей должно быть больше 1.");
} else {
scanner.nextLine();
calculated.countItems();
System.out.println("Все товары добавлены. Показать список и посчитать счет? (да/нет)");
String answer = scanner.nextLine();
if (answer.equalsIgnoreCase("да")) {
calculated.displayProducts();
calculated.calculatePerPerson(quantity);
}
return;
}
} else {
System.out.println("Введите целое число.");
scanner.next();
}
}
}
}