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
36 lines (32 loc) · 1.34 KB
/
Main.java
File metadata and controls
36 lines (32 loc) · 1.34 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
33
34
35
36
import java.util.Scanner;
// dev branch for Y.Practicum
public class Main {
public static void main(String[] args) {
System.out.println("Добрый день!");
Calculator.GoodsPrice();
}
public static int getPeopleCount() {
Scanner scanner = new Scanner(System.in);
int peopleCount=0;
System.out.println("На сколько человек разделить счет?");
while (true) {
if(scanner.hasNextInt()) {
peopleCount = scanner.nextInt();
if (peopleCount == 1) {
System.out.println("Извините, но тогда нет смысла разделять счет.");
} else if (peopleCount < 1) {
System.out.println("Извините, это некорректное значение для подсчета.");
} else {
System.out.println("Спасибо. Информация принята");
break;
}
}
else {
System.out.println("Нужно ввести число");
scanner.next();
}
System.out.println("Попробуйте ввести количество людей еще раз.");
}
return peopleCount;
}
}