Repository navigation
Expand file tree
/
Copy pathMain.java
More file actions
56 lines (42 loc) · 1.69 KB
/
Copy pathMain.java
File metadata and controls
56 lines (42 loc) · 1.69 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int person;
String menu = "";
double sum = 0;
double prisePosition;
double price;
String position;
person = PeopleNumber.count();
while (true) {
System.out.println("Введите название блюда или напишите \"завершить\" для дальнейшего подсчета:");
position = scanner.next();
if (position.equalsIgnoreCase("завершить")) {
break;
}
menu = menu + "\n" + position;
while (true) {
System.out.println("Введите цену блюда:");
scanner.nextLine();
if (scanner.hasNextDouble()) {
prisePosition = scanner.nextDouble();
if(prisePosition>0) {
sum = sum + prisePosition;
break;
} else {
System.out.println("Вы ввели некорректную цену");
}
} else {
System.out.println("Вы ввели не число");
}
}
}
price = sum/person;
System.out.println("Добавленные товары:" + menu);
String rub = Calculation.everyPeoplePrice(price);
String numberRub = String.format("%.2f", price);
System.out.println("Цена для каждого гостя: " + numberRub + " " + rub);
scanner.close();
}
}