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
28 lines (26 loc) · 1.35 KB
/
Main.java
File metadata and controls
28 lines (26 loc) · 1.35 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
import java.util.Scanner;
// dev branch for Y.Practicum
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("На скольких человек необходимо разделить счет?");
int numberOfPersons = 0;
while (true) { // Цикл для ввода кол-ва человек и вызов метода для расчета суммы на человека
if (!scanner.hasNextInt()) {
System.out.println("Необходимо ввести количество людей");
scanner.next();
} else {
numberOfPersons = scanner.nextInt();
if (numberOfPersons == 1) {
System.out.println("Ты платишь за все. Попробуй ещё раз:");
} else if (numberOfPersons <= 0) {
System.out.println("Число должно быть положительным. Введите, пожалуйста, заново:");
} else {
Calculator calculator = new Calculator();
calculator.product(numberOfPersons);
break;
}
}
}
}
}