package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.StringReader;
/*
Разные методы для разных типов
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s;
do {
s=reader.readLine();
if (s.equals("exit")) break;
int n;
try {
n = Integer.parseInt(s);
if ((n>0) && (n<128)) print((short)n);
else if ((n>=128) || (n<=0)) print(new Integer(n));
} catch (NumberFormatException e) {
if (s.contains(".")) print(new Double(s)); else print(s);
}
} while (true);
}
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);
}
}
package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.StringReader;
/*
Разные методы для разных типов
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s;
do {
s=reader.readLine();
if (s.equals("exit")) break;
int n;
try {
n = Integer.parseInt(s);
if ((n>0) && (n<128)) print((short)n);
else if ((n>=128) || (n<=0)) print(new Integer(n));
} catch (NumberFormatException e) {
if (s.indexOf(".")!=-1) {
print(new Double(s));
} else print(s);
}
} while (true);
}
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);
}
}