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
29 lines (25 loc) · 1.13 KB
/
Input.java
File metadata and controls
29 lines (25 loc) · 1.13 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
import java.util.Scanner;
public class Input {
public int input() {
System.out.println("На сколько человек разделить счёт?");
Scanner scanner = new Scanner(System.in);
int persons;
while (true) {
if (scanner.hasNextInt()) {
persons = scanner.nextInt();
if (persons < 1) {
System.out.println("А у вас руки жирные и крошки на брюках, всё же извольте ввести правельное кол-во гостей.");
} else if (persons == 1) {
System.out.println("Вы так много накушали в одного... Возможно в другой раз стоит взять с собой друга, чтобы разделить счёт.");
} else {
break;
}
} else {
System.out.println("Введите числовое значение!");
scanner.nextLine();
}
scanner.close();
}
return persons;
}
}