We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
class Solution{
public static void main(String []argh)
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
for(int i=0; i<t; i++)
{
try
{
long num = sc.nextLong();
System.out.println(num+" can be fitted in:");
if( num >= -128 && num <= 127)System.out.println("* byte");
if( num >= Short.MIN_VALUE && num <= Short.MAX_VALUE)
System.out.println("* short");
if( num >= Integer.MIN_VALUE && num <= Integer.MAX_VALUE)
System.out.println("* int");
if( num >= Long.MIN_VALUE && num <= Long.MAX_VALUE)
System.out.println("* long");
}
catch(Exception e)
{
System.out.println(sc.next()+" can't be fitted anywhere.");
}
}
}
Java Datatypes
You are viewing a single comment's thread. Return to all comments →
// try this one. clean code and now need of pow function
import java.util.; import java.io.; import java.math.*;
class Solution{ public static void main(String []argh) {
}