- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
Latest commit
45 lines (30 loc) · 1.14 KB
/
Copy pathSolution.java
File metadata and controls
45 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
importjava.util.*;
importjava.io.*;
classSolution{
publicstaticvoidmain(String[] args) {
Scannerin = newScanner(System.in);
intn = in.nextInt();
Stringarr[] = newString[n];
in.nextLine();
for (inti = 0; i < n; i++){
arr[i] = in.nextLine();
}
for (inti = 0; i < n; i++){
try{
longl = Long.parseLong(arr[i]);
System.out.println(arr[i] + " can be fitted in:");
if(l <= 127 && l >= -128){
System.out.println("* byte \n* short \n* int \n* long");
}elseif( l <= 32767 && l >= -32768){
System.out.println("* short \n* int \n* long");
}elseif ( l <= 2147483647 && l >= -2147483648){
System.out.println("* int \n* long");
}elseif(l <= 9223372036854775807l && l >= -9223372036854775808l){
System.out.println("* long");
}
}catch (NumberFormatExceptione){
System.out.println(arr[i] + " can't be fitted anywhere.");
}
}
}
}