it works correctly
but why i get error...
package com.codegym.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/*
Different methods for different types
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
while (true){
String s = r.readLine();
if(!s.equals("exit")){
try {
double a = Double.parseDouble(s);
int b = (int) a;
double d = a % b;
if(d != 0){
print(a);
}
else if(d == 0 && b > 0 && b < 128){
try {
Short sh = Short.parseShort(s);
print(sh);
}
catch (NumberFormatException e){
e.printStackTrace();
}
}
else if (d == 0 && ( a <= 0 || a >= 128 )) {
try {
Integer i = Integer.parseInt(s);
print(i);
}
catch (Exception e){
e.printStackTrace();
}
}
}
catch (NumberFormatException e){
print(s);
}
}
else {
break;
}
}
}
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);
}
/* public static boolean isInt(String s){
try {
Integer a = Integer.parseInt(s);
return true;
}
catch (Exception e){
return false;
}
}*/
}