forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
30 lines (28 loc) · 1.4 KB
/
Main.java
File metadata and controls
30 lines (28 loc) · 1.4 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Calculator calculator = new Calculator();
int quantity ;
quantity = calculator.quantityOfGuest();
while (true) {
System.out.println("Введите название товара.");
String name = scanner.nextLine();
System.out.println("Введите стоимость товара в формате: \"рубли,копейки\" [10,45]");
if (scanner.hasNextDouble()) {
double cost = scanner.nextDouble();
calculator.cheque(name, cost);
System.out.println("Хотите ли добавить еще один товар? \n" +
"(Если да,напишите любой символ ,если нет,напишите \"Завершить\". )");
} else {
System.out.println("Введено не корректное значение цены.Повторите ввод.");
}
String answer = scanner.next();
if (answer.equalsIgnoreCase("завершить")) {
calculator.finalAccount(quantity);
break;
}
scanner.nextLine();
}
}
}