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
32 lines (28 loc) · 1.14 KB
/
Main.java
File metadata and controls
32 lines (28 loc) · 1.14 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
31
32
import java.util.Scanner;
// Финальная версия
public class Main {
public static void main(String[] args) {
int countUser;
countUser = countUser();
Goods.addGoods(countUser);
}
public static int countUser() {
int countUser;
System.out.println("На скольких человек необходимо разделить счёт?");
while (true) {
Scanner scanner = new Scanner(System.in);
if (scanner.hasNextInt()) {
countUser = scanner.nextInt();
if (countUser == 1) {
System.out.println("В этом случае нет смысла ничего считать и делить. Попробуйте еще раз.");
} else if (countUser < 1) {
System.out.println("Это некорректное значение для подсчёта. Попробуйте еще раз.");
} else {
return (countUser);
}
} else {
System.out.println("Это не число");
}
}
}
}