В "judje" гърми последният тест 80 / 100 на задача "Furniture" от "Exercise: Regular Expressions"
Здравейте,
моля за съдействие. Не разбирам защо гърми на последния тест. Кода ми е:
import java.util.ArrayList;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegularExpression___Furniture {
//19:27
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
Pattern pattern = Pattern.compile
("\\>\\>(?<furnitureName>(\\w+))\\<\\<(?<price>([0-9]+\\.[0-9]{2})|(\\d+))\\!(?<quantity>([0-9]+))");
ArrayList<String> name = new ArrayList<>();
double sum = 0.0;
String furnitureName = null;
double price = 0.0;
int quantity = 0;
while (!input.equals("Purchase")) {
Matcher correctInput = pattern.matcher(input);
while (correctInput.find()) {
furnitureName = correctInput.group("furnitureName");
price = Double.parseDouble(correctInput.group("price"));
quantity = Integer.parseInt(correctInput.group("quantity"));
name.add(furnitureName);
sum += price * quantity;
}
input = scanner.nextLine();
}
System.out.println("Bought furniture:");
for (int i = 0; i < name.size(); i++) {
System.out.println(name.get(i));
}
System.out.printf("Total money spend: %.2f",sum);
}
}
Благодаря предварително за съдействието.
Благодаря за пояснението.
Пламен