Протестировал код. Выдаёт то, что надо, но валидатор не пропускает. в чем может быть ошибка?
package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/*
Разные методы для разных типов
*/
public class Solution {
public static void main(String[] args) throws IOException {
//напиште тут ваш код
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Pattern pPoint = Pattern.compile("[.]"); //ищет точку
Pattern numbers = Pattern.compile("\\d+"); //ищет любое число
while (true) {
String s = reader.readLine();
if (s.equals("exit")) break;
Matcher mP = pPoint.matcher(s);
Matcher mNum = numbers.matcher(s);
if(mP.find()) {
try {
print(Double.parseDouble(s));
} catch (NumberFormatException e) {
print(s);
}
} else if (mNum.find()){
try {
short sh = Short.parseShort(s);
if (sh > 0 && sh < 128) {
print(sh);
}
} catch (NumberFormatException e) {
print(s);
}
try {
int i = Integer.parseInt(s);
if (i <= 0 || i >= 128) {
print(i);
}
} catch (NumberFormatException ignored) {}
} else print(s);
}
}
public static void print(Double value) {
System.out.println("Это тип Double, значение " + value);
}
public static void print(String value) {
System.out.println("Это тип String, значение " + value);
}
public static void print(short value) {
System.out.println("Это тип short, значение " + value);
}
public static void print(Integer value) {
System.out.println("Это тип Integer, значение " + value);
}
}