Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner sc = new Scanner(System.in);
- int t=sc.nextInt();
- while(sc.hasNext())
- {
- try
- {
- long x=sc.nextLong();
- System.out.println(x+" can be fitted in:");
- if(x>=-128 && x<=127)System.out.println("* byte");
- if(x>=-pow(2,15) && x<pow(2,15))System.out.println("* short");
- if(x>=-(long)pow(2,31) && x<(long)pow(2,31))System.out.println("* int");
- if(x>=-(long)pow(2,63) && x<(long)pow(2,63))System.out.println("* long");
- //Complete the code
- }
- catch(Exception e)
- {
- System.out.println(sc.next()+" can't be fitted anywhere.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement