Pls I've tried my best ... and its still not working Esp the Integer and String part
package com.codegym.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Scanner;
/*
Different methods for different types
*/
public class Solution {
public static void main(String[] args) throws IOException {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String input = reader.readLine();
if (input.equals("exit")) {
break;
}
try {
if (input.contains(".")) {
double d = Double.parseDouble(input);
print(d);
} else if (Short.parseShort(input) > 0 && Short.parseShort(input) < 128) {
short s = Short.parseShort(input);
print(s);
} else {
Integer i = Integer.parseInt(input);
print(i);
}
} catch (Exception e) {
print(input);
}
}
}
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);
}
}