Java Datatypes

  • + 0 comments

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        Scanner sc= new Scanner(System.in);
        int NumberOfInput= sc.nextInt();
    
    
       for (int i = 0; i < NumberOfInput; i++) {
    
    
    
            try{
                Long InputValue= sc.nextLong();
                 System.out.println(InputValue+" "+"can be fitted in:");
             if (InputValue>=Byte.MIN_VALUE &&InputValue<=Byte.MAX_VALUE) {
                 System.out.println("* byte");
             }
             if (InputValue>=Short.MIN_VALUE &&InputValue<=Short.MAX_VALUE) {
                 System.out.println("* short");
             }
              if (InputValue>=Integer.MIN_VALUE &&InputValue<=Integer.MAX_VALUE) {
                 System.out.println("* int");
             }
    
               if (InputValue>=Long.MIN_VALUE && InputValue<=Long.MAX_VALUE) {
                 System.out.println("* long");
             }
    
    
            }catch(Exception e){
                System.out.println(sc.next() +" "+"can't be fitted anywhere.");
            }
    
    
    
    
    
       }
    }
    

    }