it works perfectly fine but I cant pass the requirments
package com.codegym.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.*;
/*
Different methods for different types
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
Scanner sca = new Scanner(System.in);
ArrayList<String> words = new ArrayList<String>();
while(true)
{
String str = sca.nextLine();
if(!str.equals("exit"))
{
words.add(str);
}
else break;
}
String[] strs = words.toArray(new String[0]);
for(int i=0;i<strs.length;i++)
{
if(strs[i].contains("."))
{
print(Double.parseDouble(strs[i]));
}
else
{
try{
int x = Integer.parseInt(strs[i]);
if(x<128&&x>0)
{print(Short.parseShort(strs[i]));}
else {print(Integer.parseInt(strs[i]));}
}catch(Exception e){print(strs[i]);}
}
}
}
public static void print(Double value) {
System.out.println("This is a Double. Value: " + value);
}
public static void print(String value) {
System.out.println("This is a String. Value: " + value);
}
public static void print(short value) {
System.out.println("This is a short. Value: " + value);
} ;
public static void print(Integer value) {
System.out.println("This is an Integer. Value: " + value);
}
}