-
Notifications
You must be signed in to change notification settings - Fork 220
Expand file tree
/
Copy pathMain.java
More file actions
33 lines (25 loc) · 1.33 KB
/
Main.java
File metadata and controls
33 lines (25 loc) · 1.33 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 Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("На скольких человек необходимо разделить счёт?");
while (!scanner.hasNextInt()){ // Проверяем, ввели ли значение типа int
scanner.next();
System.out.println("Вы ввели неверное значение, попробуйте еще раз: ");
}
int amountOfPersons = scanner.nextInt();
while (amountOfPersons < 2) { // если значенние 0,1 или отрицательное, запрашиваем ввод снова
System.out.println("В таком случае нет смысла считать :\nВведите значение еще раз: ");
while (!scanner.hasNextInt()) {
scanner.next();
}
amountOfPersons = scanner.nextInt();
}
System.out.println("Кол-во персон: " + amountOfPersons);
Product products = new Product();
products.saveProducts();
Calculator calculator = new Calculator();
calculator.calculate(amountOfPersons, products.totalSumOfProducts);
calculator.correctOutput();
}
}