.
package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/*
Разные методы для разных типов
*/
public class Solution {
public static void main(String[] args) throws IOException {
//напиште тут ваш код
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String string =null; // Строка что будет вводится
Double d = 0.0; // Тип Double для - print()
short s = 0; // Тип short для - print()
Integer i = 0; // Тип Integer для - print
while (true){
string = reader.readLine();
int a = 0;
int b = 0; // Переменные для проверки
int c = 0;
if(string.equals("exit")){
break;
}
if(string.contains(".")) {
d = Double.parseDouble(string);
print(d);
a = 1; // Если Double то a = 1;
}
try { //Исключение для 34 строки
i = Integer.parseInt(string);
if(string.contains(".") == false &&(i> 0 && i < 128)){
s = Short.parseShort(string);
print(s);
b =1; // Если short то c = 1;
}
else if( string.contains(".") == false && (i <= 0 || i >= 128)){
print(i);
c = 1; // Если Integer то c = 1;
}
}
catch (NumberFormatException n){
}
if(a == 0 && b ==0 && c ==0){ //Если не одной из переменных не присваивалось значение, то string
print(string);
}
}
}
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);
}
}