You are viewing a single comment's thread. Return to all 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); String s = sc.next(); while (sc.hasNext()) { s = sc.next(); boolean fitted = false, bFit = false, shFit = false, iFit = false, lFit = false; try { byte b = Byte.valueOf(s); if (b >= Byte.MIN_VALUE && b <= Byte.MAX_VALUE) { bFit = true; fitted = true; } } catch (Exception e) { } try { short sh = Short.valueOf(s); if (sh >= Short.MIN_VALUE && sh <= Short.MAX_VALUE) { shFit = true; fitted = true; } } catch (Exception e) { } try { int i = Integer.valueOf(s); if (i >= Integer.MIN_VALUE && i <= Integer.MAX_VALUE) { iFit = true; fitted = true; } } catch (Exception e) { } try { long l = Long.valueOf(s); if (l >= Long.MIN_VALUE && l <= Long.MAX_VALUE) { lFit = true; fitted = true; } } catch (Exception e) { } if (!fitted) { System.out.println("".concat(s.concat(" can't be fitted anywhere."))); } else { System.out.println(s.concat(" can be fitted in:")); if (bFit) { System.out.println("* byte"); } if (shFit) { System.out.println("* short"); } if (iFit) { System.out.println("* int"); } if (lFit) { System.out.println("* long"); } } } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Datatypes
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
}