forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTovar.java
More file actions
30 lines (24 loc) · 1.03 KB
/
Tovar.java
File metadata and controls
30 lines (24 loc) · 1.03 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
import java.util.Scanner;
public class Tovar {
static Scanner sc = new Scanner(System.in);
static String nameTovar;
static double bufCost;
public static void inputTovar() {
System.out.println("Введите название товара ");
nameTovar = sc.next();
}
public static void inputCost() {
System.out.println("Введите стоимость товара ");
do {
while (!sc.hasNextDouble()) {
System.out.println("Неправильно!Введите стоимость цифрами, а копейки через запятую!");
sc.next();
}
bufCost = sc.nextDouble();
if(bufCost<=0) {
System.out.println("Стоимость не может быть отрицательная стоимость или равняться 0!");
System.out.println("Повторите ввод стоимости!");
}
} while(bufCost<=0);
}
}