I don't understand how to put the code to be able to call print(String ) after 4 hours of work, any hint? Tk you!
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 {
//write your code here
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = "";
while(!s.equals("exit")){
s = br.readLine();
try{
if(s.contains(".")){
Double d = Double.parseDouble(s);
print(d);
}
int i = Integer.parseInt(s);
if( i <= 0 || i >= 128){
print(i);
} else
print((short) i);
} catch (NumberFormatException e){
print(s);
}
}
}
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);
}
}