forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
32 lines (30 loc) · 1.16 KB
/
Main.java
File metadata and controls
32 lines (30 loc) · 1.16 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) {
Scanner scanner = new Scanner(System.in);
int people = addPerson(scanner);
Calculator calculator = new Calculator();
for(int i = 0; i <= people; i++) {
calculator.productsLists(scanner);
}
}
public static int addPerson(Scanner scanner) {
int people = 0;
boolean hasPeople = false;
while(!hasPeople) {
System.out.println("Введите количество человек:");
if (scanner.hasNextInt()) {
people = scanner.nextInt();
if (people > 1) {
hasPeople = true;
} else {
System.out.println("Введено неверное количество. попробуйте еще раз.");
}
}else {
System.out.println("Введено неверное количество! попробуйте ввести количество гостей в виде числа.");
scanner.nextLine();
}
}
return people;
}
}