if statement working but not displaying output [on hold]












-2















The code is to print that the input number belongs to which data-types. The problem is that the last if statement works but, does not print the output.



import java.util.*;
import java.io.*;
import java.lang.Math;



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 x=sc.nextLong();
double low = Math.pow(-2,31);
double up = Math.pow(2,31);
double low1 = Math.pow(-2,63);
double up1 = Math.pow(2,64);
System.out.println(x+" can be fitted in:");
if(x>=-128 && x<=127)System.out.println("* byte");
if(-32768<=x && x<=32767)System.out.println("* short");
if((int)low<=x && x<=(int)up - 1)System.out.println("* int");
if((int)low1<=x && x<=((int)up1 - 1) )System.out.println("* long");

}
catch(Exception e)
{
System.out.println(sc.next()+" can't be fitted anywhere.");
}

}
}
}









share|improve this question







New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Martin R, Mast, AJNeufeld, ratchet freak, Hosch250 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Martin R, Mast, AJNeufeld, ratchet freak, Hosch250

If this question can be reworded to fit the rules in the help center, please edit the question.














  • Welcome to StackExchange sites. This question reports unexpected behavior so it's more appropriate to be asked on StackOverflow rather than CodeReview.

    – dbl
    13 hours ago











  • If it doesn't print the output while it should, why do you think it still works?

    – Mast
    13 hours ago
















-2















The code is to print that the input number belongs to which data-types. The problem is that the last if statement works but, does not print the output.



import java.util.*;
import java.io.*;
import java.lang.Math;



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 x=sc.nextLong();
double low = Math.pow(-2,31);
double up = Math.pow(2,31);
double low1 = Math.pow(-2,63);
double up1 = Math.pow(2,64);
System.out.println(x+" can be fitted in:");
if(x>=-128 && x<=127)System.out.println("* byte");
if(-32768<=x && x<=32767)System.out.println("* short");
if((int)low<=x && x<=(int)up - 1)System.out.println("* int");
if((int)low1<=x && x<=((int)up1 - 1) )System.out.println("* long");

}
catch(Exception e)
{
System.out.println(sc.next()+" can't be fitted anywhere.");
}

}
}
}









share|improve this question







New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











put on hold as off-topic by Martin R, Mast, AJNeufeld, ratchet freak, Hosch250 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Martin R, Mast, AJNeufeld, ratchet freak, Hosch250

If this question can be reworded to fit the rules in the help center, please edit the question.














  • Welcome to StackExchange sites. This question reports unexpected behavior so it's more appropriate to be asked on StackOverflow rather than CodeReview.

    – dbl
    13 hours ago











  • If it doesn't print the output while it should, why do you think it still works?

    – Mast
    13 hours ago














-2












-2








-2








The code is to print that the input number belongs to which data-types. The problem is that the last if statement works but, does not print the output.



import java.util.*;
import java.io.*;
import java.lang.Math;



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 x=sc.nextLong();
double low = Math.pow(-2,31);
double up = Math.pow(2,31);
double low1 = Math.pow(-2,63);
double up1 = Math.pow(2,64);
System.out.println(x+" can be fitted in:");
if(x>=-128 && x<=127)System.out.println("* byte");
if(-32768<=x && x<=32767)System.out.println("* short");
if((int)low<=x && x<=(int)up - 1)System.out.println("* int");
if((int)low1<=x && x<=((int)up1 - 1) )System.out.println("* long");

}
catch(Exception e)
{
System.out.println(sc.next()+" can't be fitted anywhere.");
}

}
}
}









share|improve this question







New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












The code is to print that the input number belongs to which data-types. The problem is that the last if statement works but, does not print the output.



import java.util.*;
import java.io.*;
import java.lang.Math;



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 x=sc.nextLong();
double low = Math.pow(-2,31);
double up = Math.pow(2,31);
double low1 = Math.pow(-2,63);
double up1 = Math.pow(2,64);
System.out.println(x+" can be fitted in:");
if(x>=-128 && x<=127)System.out.println("* byte");
if(-32768<=x && x<=32767)System.out.println("* short");
if((int)low<=x && x<=(int)up - 1)System.out.println("* int");
if((int)low1<=x && x<=((int)up1 - 1) )System.out.println("* long");

}
catch(Exception e)
{
System.out.println(sc.next()+" can't be fitted anywhere.");
}

}
}
}






java






share|improve this question







New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 13 hours ago









rogerroger

1




1




New contributor




roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






roger is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




put on hold as off-topic by Martin R, Mast, AJNeufeld, ratchet freak, Hosch250 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Martin R, Mast, AJNeufeld, ratchet freak, Hosch250

If this question can be reworded to fit the rules in the help center, please edit the question.




put on hold as off-topic by Martin R, Mast, AJNeufeld, ratchet freak, Hosch250 12 hours ago


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – Martin R, Mast, AJNeufeld, ratchet freak, Hosch250

If this question can be reworded to fit the rules in the help center, please edit the question.













  • Welcome to StackExchange sites. This question reports unexpected behavior so it's more appropriate to be asked on StackOverflow rather than CodeReview.

    – dbl
    13 hours ago











  • If it doesn't print the output while it should, why do you think it still works?

    – Mast
    13 hours ago



















  • Welcome to StackExchange sites. This question reports unexpected behavior so it's more appropriate to be asked on StackOverflow rather than CodeReview.

    – dbl
    13 hours ago











  • If it doesn't print the output while it should, why do you think it still works?

    – Mast
    13 hours ago

















Welcome to StackExchange sites. This question reports unexpected behavior so it's more appropriate to be asked on StackOverflow rather than CodeReview.

– dbl
13 hours ago





Welcome to StackExchange sites. This question reports unexpected behavior so it's more appropriate to be asked on StackOverflow rather than CodeReview.

– dbl
13 hours ago













If it doesn't print the output while it should, why do you think it still works?

– Mast
13 hours ago





If it doesn't print the output while it should, why do you think it still works?

– Mast
13 hours ago










0






active

oldest

votes

















0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

How to make a Squid Proxy server?

Is this a new Fibonacci Identity?

19世紀