forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
28 lines (25 loc) · 1.04 KB
/
Main.java
File metadata and controls
28 lines (25 loc) · 1.04 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
import java.util.Scanner;
public class Main {
static int Guests;
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 {
Guests = i;
break;
}
} else {
System.out.println("Введите целое число гостей");
scanner.nextLine();
}
}
return Guests;
}
}