Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (35 loc) · 1.68 KB
/
Copy pathMain.java
File metadata and controls
39 lines (35 loc) · 1.68 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
//Уважаемый ревьюрер, я забыл при прошлом отправлении сделать коммит, прошу прощения.
while (true) {
System.out.println("На сколько человек хотите разделить покупку?");
Scanner scan = new Scanner(System.in);
int n = Actions.GetNumber(scan);
if (n == 1) {
System.out.println("Ощибка! Введите значение >1!");
} else if (n < 1) {
System.out.println("Ощибка! Некорректное число! Введите значение >1!");
} else {
double prices = 0.0;
String products = "";
while (true) {
System.out.println("Введите название товара или \"Завершить!\"");
scan.nextLine();
String name = scan.nextLine();
if (name.equalsIgnoreCase("Завершить")) {
System.out.println("Ваши товары: \n" + products);
Actions.ShowResult(prices / n);
scan.close();
break;
} else {
double price = Actions.GetProductPrice(scan);
prices = Actions.GetPrices(price, prices);
products = Actions.GetProducts(name, products);
}
}
break;
}
}
}
}