forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalkulater.java
More file actions
55 lines (40 loc) · 1.72 KB
/
Calkulater.java
File metadata and controls
55 lines (40 loc) · 1.72 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
package org.example;
import java.util.Scanner;
public class Calkulater {
Scanner sc = new Scanner(System.in);
String nameOfDishes = "";
String nameOfDishesAll = "";
double cost;
private double summ = 0;
private double moneyPerPerson = 0;
void calk(int person) {
org.example.Ostatok rur = new org.example.Ostatok();
while (true) {
System.out.println("Введите Название блюда");
nameOfDishes = sc.next();
if (!(nameOfDishes.equalsIgnoreCase("Завершить"))) {
System.out.println("Введите стоимость в формате рублей.копеек");
while (true) {
while (!sc.hasNextDouble()) {
System.out.println("Введены буквы вместо цифр");
sc.next();
}
cost = sc.nextDouble();
if (cost <= 0) {
System.out.println("Не корректная цифра");
} else {
break;
}
}
summ = summ + cost;
nameOfDishesAll = nameOfDishesAll + "\n" + nameOfDishes;
String messageTemplate1 = "Вы успешно добавили товар на общую сумму %.2f руб., добавьте товар еще, или наберите слово Завершить \n";
System.out.printf(messageTemplate1, summ);
} else {
break;
}
}
moneyPerPerson = summ / person;
rur.ostat(moneyPerPerson, nameOfDishesAll);
}
}