-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsers.java
More file actions
30 lines (24 loc) · 1.01 KB
/
Users.java
File metadata and controls
30 lines (24 loc) · 1.01 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
30
import java.util.Scanner;
public class Users {
public static int users;
public static void persons() {
Scanner scanner = new Scanner(System.in);
//вводим бесконечный цикл, чтобы пользователь мог ввести правильное значение
while (true) {
System.out.println("Выберите количество человек");
if (scanner.hasNextInt()) {
users = scanner.nextInt();
if (users>1) {
System.out.println("Колличество пользователей = " + users);
break;
}
if(users<=1){
System.out.println("Введите корректные данные. Значение должно быть больше 1");
}
} else {
System.out.println("Введите корректные данные");
scanner.nextLine();
}
}
}
}