forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStuff.java
More file actions
68 lines (31 loc) · 1.21 KB
/
Stuff.java
File metadata and controls
68 lines (31 loc) · 1.21 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
import java.util.Scanner;
public class Stuff {
public static String name() {
Scanner scanner = new Scanner(System.in);
return scanner.nextLine();
}
public static double priceStuf(String name) {
Scanner scanner = new Scanner(System.in);
String keyWOrd1 = "завершить";
double price = 0;
if (name.equalsIgnoreCase(keyWOrd1)) {
return 0;
} else {
while (!scanner.hasNextDouble()) {
System.out.println("Допустимы только цифры, попробуйте еще раз");
scanner.next();
}
while (scanner.hasNextDouble()) {
price = scanner.nextDouble();
if (price < 0) {
System.out.println("Допустимы только положительные значения, попробуйте еще раз");
}else {
System.out.println("Добавлено успешно");
System.out.println("Что нибудь еще?");
return price;
}
}
}
return price;
}
}