-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathMain.java
More file actions
108 lines (103 loc) · 3.99 KB
/
Main.java
File metadata and controls
108 lines (103 loc) · 3.99 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Здравствуйте! На сколько человек разделить счёт?");
Scanner scanner = new Scanner(System.in);
int x = 0;
while (true) {
try {
x = scanner.nextInt();
if (x >= 2) { // если пользователь вводит корректное значение
System.out.println();
break;
}
} catch (Exception e) {
scanner.next();
}
System.out.println("Введено некорректное значение, попробуйте еще.");
}
Calculator.calculator(x);
}
//
//
// public static void calculator(int delitel) {
//
// Scanner scannerProduct = new Scanner(System.in);
// String allProduct = "";
// Float allPrice = 0.0f;
// while (true) {
// System.out.println("Введите название товара");
// String product = scannerProduct.next();
// String and = "Завершить";
// if (product.equalsIgnoreCase(and)) {
// break;
// }
//
// System.out.println("Введите стоимость товара (рубли.копейки)");
// Float price = cost();
// allProduct = allProduct + "\n" + product + ": " + price;
// allPrice = allPrice + price;
// System.out.println("Товар добавлен, хотите добавить еще товар ? \n Если нет, введите команду \"Завершить\"");
// String answer = scannerProduct.next();
// if (answer.equalsIgnoreCase(and)) {
// break;
// }
//
// }
// float personPrice = allPrice / delitel;
// String personPriceString = String.format("%.2f", personPrice);
// int personPriceInteger = (int) personPrice;
// String rub = conjugation(personPriceInteger);
// System.out.println("Добавленные товары:" + "\n" + allProduct + "\n" + "Сумма к оплате для каждого человека - " + personPriceString + rub);
//
// }
//
// //введение цены
// public static float cost() {
// Scanner scanner = new Scanner(System.in);
// float price = 0.0f;
// try {
// String value = scanner.next().trim();
// price = Float.parseFloat(value);
// int pointPosition = value.indexOf('.');
// if (!(pointPosition == -1 || value.length() - 1 - pointPosition <= 2)) {
// System.out.println("Введено некорректное значение, попробуйте еще.");
// price = cost();
// }
// if (price > 0) {
// System.out.println("Введено некорректное значение, попробуйте еще.");
// price = cost();
// }
// } catch (Exception e) {
// System.out.println("Введено некорректное значение, попробуйте еще.");
// price = cost();
// }
//
// return price;
// }
// public static String conjugation(int integer) {
// int remainder = integer % 100;
// if (remainder >= 11 && remainder <= 14) {
// return "рублей";
// }
// remainder = integer % 10;
// switch (remainder) {
// case 1:
// return "рубль";
// case 2:
// case 3:
// case 4:
// return "рубля";
// case 0:
// case 5:
// case 6:
// case 7:
// case 8:
// case 9:
// return "рублей";
// default:
// return "рубль";
// }
//
// }
}