Advertisement
Guest User

Untitled

a guest
Sep 25th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Scanner sc = new Scanner(System.in);
  2. int t=sc.nextInt();
  3.  
  4. while(sc.hasNext())
  5. {
  6.  
  7. try
  8. {
  9. long x=sc.nextLong();
  10. System.out.println(x+" can be fitted in:");
  11. if(x>=-128 && x<=127)System.out.println("* byte");
  12. if(x>=-pow(2,15) && x<pow(2,15))System.out.println("* short");
  13. if(x>=-(long)pow(2,31) && x<(long)pow(2,31))System.out.println("* int");
  14. if(x>=-(long)pow(2,63) && x<(long)pow(2,63))System.out.println("* long");
  15.  
  16. //Complete the code
  17. }
  18. catch(Exception e)
  19. {
  20. System.out.println(sc.next()+" can't be fitted anywhere.");
  21. }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement