forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.java
More file actions
20 lines (17 loc) · 894 Bytes
/
Calculator.java
File metadata and controls
20 lines (17 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class Calculator {
String listOfGoods = "";
double totalPrice = 0;
public void formAListOfGoodsAndTheirPrice() {
while (true) {
Item item = new Item();
String nameOfItem = item.addAnItem();
double priceOfItem = item.addAnItemPrice();
listOfGoods += nameOfItem + " " + String.format("%.2f", item.priceOfItem) + "\n";
totalPrice += priceOfItem;
System.out.println("Товар успешно добавлен! Вы хотите добавить еще товар?");
System.out.println("Введите команду \"Завершить\" для того, чтоб завершить процесс добавления товаров.");
String addOneMore = Main.sc.nextLine();
if (addOneMore.equalsIgnoreCase("завершить")) break;
}
}
}