Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- AI(reader.readLine());
- }
- 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);
- }
- static void AI(String key) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- while (!((key = reader.readLine()).equals("exit"))) {
- try {
- int value = Integer.parseInt(key);
- if (value > 0 && value < 128) {
- print((short) value);
- } else print(value);
- } catch (NumberFormatException e) {
- try {
- print(Double.parseDouble(key));
- } catch (NumberFormatException e1) {
- print(key);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement