-
Notifications
You must be signed in to change notification settings - Fork 217
Expand file tree
/
Copy pathCountOfGuests.java
More file actions
28 lines (25 loc) · 1.18 KB
/
CountOfGuests.java
File metadata and controls
28 lines (25 loc) · 1.18 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
import java.util.Scanner;
public class CountOfGuests {
static int count; // число гостей
static Scanner scanner = new Scanner(System.in);
public static int countOfGuests() {
System.out.println("Здравствуйте! На сколько человек необходимо разделить счет?");
while (true) {
if (scanner.hasNextInt()) {
int i = scanner.nextInt();
if (i == 1) {
System.out.println("Для одного гостя разбивать счёт нет необходимости. Введите другое число гостей");
} else if (i < 1) {
System.out.println("Гости не пришли. Платить некому. Введите другое число гостей.");
} else {
count = i; // запомнили число гостей
break;
}
} else {
System.out.println("Введите целое число");
scanner.nextLine();
}
}
return count;
}
}