Java Datatypes

  • + 0 comments

    hey i dont know why the code is not running properly :

    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 t = sc.nextInt();
    
        for(int i = 0; i < t; i++){
            try{
                long a = sc.nextLong();
                System.out.println(a+" can be fitted in:");
    
                if(a >= Byte.MIN_VALUE && a <= Byte.MAX_VALUE){
                    System.out.println("* byte");
                }
                if(a >= Short.MIN_VALUE && a <= Short.MAX_VALUE) {
                    System.out.println("* short");
                } 
                if(a >= Integer.MIN_VALUE && a <= Integer.MAX_VALUE){
                    System.out.println("* int");
                }
                if (a >= Long.MIN_VALUE && a <= Long.MAX_VALUE) {
                    System.out.println("* long");
                }
            }catch(Exception e){
                String x = sc.next();
                System.out.println(x+" can't  be fitted anywhere.");
            }
        }
        sc.close();
    }
    

    }