forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersons.java
More file actions
23 lines (19 loc) · 821 Bytes
/
Persons.java
File metadata and controls
23 lines (19 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class Persons {
public static void enterPersons() {
Scanner scanner = new Scanner(System.in);
System.out.println("На скольких человек разделить счёт?\nВведите количество посетителей от 2 до 1000");
while (true) {
if (scanner.hasNextInt()) {
Main.persons = scanner.nextInt();
if (Main.persons > 1 && Main.persons < 1000) {
System.out.printf("Введено %d посетителей\n", Main.persons);
break;
}
} else {
System.out.println("Ошибка ввода. Попробуйте ещё раз.");
scanner.next();
}
}
}
}