Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
64 lines (51 loc) · 2.37 KB
/
Copy pathMain.java
File metadata and controls
64 lines (51 loc) · 2.37 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int sumGuests;
String inputName;
Double inputPrice;
String totalList = "";
Double totalPrice = 0.00;
System.out.println("Введите количество гостей: ");
while (true) {
sumGuests = scanner.nextInt();
if (sumGuests > 1) {
System.out.println("Количество гостей: " + sumGuests + ". На них и поделим счет!");
break;
}
if (sumGuests == 1) {
System.out.println("Количество гостей: " + sumGuests + " гость. Тут и делить-то нечего");
}
if (sumGuests <= 0) {
System.out.println("Введено неверное значение. Введите целое число, больше 1");
}
System.out.println("Введите количество гостей: ");
}
while (true) {
System.out.println("Введите название продукта: ");
inputName = scanner.nextLine();
String check = "завершить";
if (inputName.equalsIgnoreCase(check)) {
System.out.println("подсчет завршен");
break;
}
if (!(inputName.equalsIgnoreCase(check))) {
totalList = totalList + "\n" + inputName;
System.out.println(totalList + " \n ");
System.out.println("Введите стоимость продукта: ");
while (true) {
inputPrice = scanner.nextDouble();
if (scanner.hasNextDouble()) {
totalPrice = totalPrice + inputPrice;
System.out.println("Итого " + totalPrice + " рублей.");
}
if (inputPrice <= 0) {
System.out.println("Повторите ввод, введены неверные данные");
break;
}
}
}
}
}
}