public static void main(String[] args) { Scanner input = new Scanner(System.in); while (input.hasNextLine()) { BigInteger number = new BigInteger(input.nextLine()); int bitLength = number.bitlength(); if (bitLength <= Bytes.SIZE) System.out.println("\u8211 byte"); if (bitLength <= Short.SIZE) System.out.println("\u8211 short"); if (bitLength <= Int.SIZE) System.out.println("\u8211 int"); if (bitLength <= Long.SIZE) System.out.println("\u8211 long"); if (bitLength > Long.SIZE) System.out.println(number + " can't be fitted anywhere."); } }
Task: find a suitable data type Input Example: 5
-150 150000 1500000000 213333333333333333333333333333333333 -100000000000000
Output Example:
-150 can be fitted in: short int long 150000 can be fitted in: int long 1500000000 can be fitted in: int long 213333333333333333333333333333333333 can't be fitted anywhere. -100000000000000 can be fitted in: long
Error 1:
error: cannot find symbol int bitLength = number.bitlength(); ^
Error 2:
symbol: method bitlength() location: variable number of type BigInteger
Error 3:
error: cannot find symbol if (bitLength <= Int.SIZE) ^ symbol: variable Int location: class Solution
source share