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
27 lines (24 loc) · 972 Bytes
/
Main.java
File metadata and controls
27 lines (24 loc) · 972 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
import java.util.Scanner;
import java.util.InputMismatchException;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int people = 0;
while (true) {
System.out.println("Введите число гостей");
try {
people = scanner.nextInt();
if (people < 1){
System.out.println("Гостей должно быть больше 1");
}
else if (people == 1) {
System.out.println("Гость не может быть один");} else if (people > 1) {
break;}
} catch (InputMismatchException exception) {
System.out.println("`Введите целое число");
scanner.next();
}
}
System.out.println("Число гостей: " + people);
}
}