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
77 lines (58 loc) · 2.98 KB
/
Main.java
File metadata and controls
77 lines (58 loc) · 2.98 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
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double totalSum = 0;
String answer;
String answer1 = "Завершить";
ArrayList<String> plates = new ArrayList<>();
String plateName;
double platePrice;
String ruble = "";
Scanner scanner = new Scanner(System.in);
System.out.println("На скольких человек необходимо разделить счет?");
int countOfPersons = scanner.nextInt();
if (countOfPersons <= 1) {
System.out.println("Вы ввели недопустимое число пользователей");
System.out.println("Введите количество гостей еще раз, пожалуйста : ");
} else {
while (true) {
System.out.println("Введите название товара: ");
plateName = scanner.next();
plates.add(plateName);
System.out.println(plateName + " успешно добавлен к заказу.");
System.out.println("Добавленные товары: " + plateName);
System.out.println("Введите цену товара: ");
platePrice = scanner.nextDouble();
totalSum += platePrice;
System.out.println("Хотите завершить заказ? ");
answer = scanner.next();
if (answer.equalsIgnoreCase(answer1))
break;
}
System.out.println("Добавленные товары: " + plates);
if ((Math.floor(totalSum / countOfPersons) / 10) == 1) {
ruble = "рубль";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 2) {
ruble = "рубля";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 3) {
ruble = "рубля";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 4) {
ruble = "рубля";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 5) {
ruble = "рублей";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 6) {
ruble = "рублей";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 7) {
ruble = "рублей";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 8) {
ruble = "рублей";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 9) {
ruble = "рублей";
} else if ((Math.floor(totalSum / countOfPersons) / 10) == 0) {
ruble = "рублей";
}
System.out.printf("К оплате с человека: " + (Math.floor(totalSum / countOfPersons) + ruble));
}
}
}