Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public class Solution {
  2. public static void main(String[] args) throws IOException {
  3. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  4. AI(reader.readLine());
  5. }
  6.  
  7.  
  8. public static void print(Double value) {
  9. System.out.println("Это тип Double, значение " + value);
  10. }
  11.  
  12. public static void print(String value) {
  13. System.out.println("Это тип String, значение " + value);
  14. }
  15.  
  16. public static void print(short value) {
  17. System.out.println("Это тип short, значение " + value);
  18. }
  19.  
  20. public static void print(Integer value) {
  21. System.out.println("Это тип Integer, значение " + value);
  22. }
  23.  
  24. static void AI(String key) throws IOException {
  25. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  26. while (!((key = reader.readLine()).equals("exit"))) {
  27. try {
  28. int value = Integer.parseInt(key);
  29. if (value > 0 && value < 128) {
  30. print((short) value);
  31. } else print(value);
  32. } catch (NumberFormatException e) {
  33. try {
  34. print(Double.parseDouble(key));
  35. } catch (NumberFormatException e1) {
  36. print(key);
  37. }
  38. }
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement