-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatatypes.java
More file actions
42 lines (34 loc) · 1.18 KB
/
Datatypes.java
File metadata and controls
42 lines (34 loc) · 1.18 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
/*
https://www.hackerrank.com/challenges/java-datatypes
*/
import java.util.*;
import java.io.*;
class Solution{
public static Scanner input = new Scanner(System.in);
public static void main(String []argh){
int t=input.nextInt();
for(int i=0;i<t;i++){
try{
long x=input.nextLong();
System.out.println(x+" can be fitted in:");
// Start Code
// -128 .. 127
if(x>=Byte.MIN_VALUE && x<=Byte.MAX_VALUE)
System.out.println("* byte");
// -32,768 .. 32767
if(x>=Short.MIN_VALUE && x<=Short.MAX_VALUE)
System.out.println("* short");
// -2,147,483,648 .. 2,147,483,647
if(x>=Integer.MIN_VALUE && x<=Integer.MAX_VALUE)
System.out.println("* int");
// -9,223,372,036,854,775,808 .. 9,223,372,036,854,775,807
if(x>=Long.MIN_VALUE && x<=Long.MAX_VALUE)
System.out.println("* long");
// End Code
}
catch(Exception e){
System.out.println(input.next()+" can't be fitted anywhere.");
}
}
}
}