-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathMain.java
More file actions
27 lines (21 loc) · 964 Bytes
/
Main.java
File metadata and controls
27 lines (21 loc) · 964 Bytes
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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int numberOfGuests = getNumberOfGuests();
Calculator.printResult(numberOfGuests);
}
static int getNumberOfGuests() {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("Введите количество гостей.");
int number = scanner.nextInt();
if (number == 1) {
System.out.println("Количество гостей дожно быть не менее 2-х человек. Найдите кого-нибудь, с кем можно разделить счёт.");
} else if (number < 2) {
System.out.println("Количество гостей не может быть меньше 1. Вероятно вы ошиблись.");
} else {
return number;
}
}
}
}