Advertisement
Guest User

Untitled

a guest
May 26th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Solving {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner read = new Scanner(System.in);
  7.  
  8.         String input;
  9.  
  10.         while (!"END".equals(input=read.nextLine())){
  11.  
  12.             if (checkInteger(input)){
  13.                 System.out.println(input+" is integer type");
  14.             }else if (checkDouble(input)){
  15.                 System.out.println(input+" is floating point type");
  16.             } else if (input.length()==1){
  17.                 System.out.println(input+" is character type");
  18.             }else if (input.equalsIgnoreCase("true")||input.equalsIgnoreCase("false")){
  19.                 System.out.println(input+" is boolean type");
  20.             }else {
  21.                 System.out.println(input+" is string type");
  22.             }
  23.         }
  24.     }
  25.  
  26.     private static boolean checkDouble(String input) {
  27.         try {
  28.             Double.parseDouble(input);
  29.             return true;
  30.         }catch (Exception e){
  31.             return false;
  32.         }
  33.     }
  34.  
  35.     private static boolean checkInteger(String input){
  36.  
  37.         try {
  38.             Integer.parseInt(input);
  39.             return true;
  40.         }catch (NumberFormatException ex){
  41.             return false;
  42.         }
  43.  
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement