-5

i want to out put like this-

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

    import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;

    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. */
        byte b;
        long l;
        int t, v;
        int[] n;
        Scanner in=new Scanner(System.in);
        System.out.println("Inter the number");
        v=in.nextInt();
        n=new int[v];
        int i=0;
        while(n.hasNextInt())
            {
            n[i]=in.nextInt();
            i++;
        }
        for(int k=0;k<t;k++)
            {if(b<n[k])
              {  
                System.out.println(k+"this is fit in");
                System.out.println("*short");
                System.out.println("*int");
                System.out.println("*long");}
             else if(t==n[k]){
                System.out.println(n[k]+"this is fit in");
                System.out.println("int");
             System.out.println("long");}
            else if(t<=n[k]){
                System.out.println(n[k]+"this is fit in");
                System.out.println("int");
                System.out.println("long");}
            else if((t<=n[k])&&(l==n[k])){
                System.out.println(n[k]+"this is fit in");
                System.out.println("long");}
            else{
                System.out.println(n[k]+"this not fitted any where");}}}}
    
Java_mad
  • 19
  • 1

2 Answers2

0

I expect it's the fact you have no logical join (&& or ||) and value here:

else if(t<=n[k]>){
// ------------^

Also note that the type int[] has no hasNextInt method, so this line:

while(n.hasNextInt())

won't compile (as n is int[]).

There are about a half dozen other logic errors in there (using uninitialized variables, etc.), but hopefully that gets you headed the right way.

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
0

A quick fix is to use an IDE like eclipse or netbeans that formats your code and makes life far easier to debug, develop in open-source and reduces the development time. Coming to the errors: I can spot that you have missed a } at the end of the program script and I notice a syntactically wrong statement:

} else if (t <= n[k] > ) {

Please confirm to correct syntactically code and use formatting to enable fellow developers help you. Good luck!

Nagabhushan Baddi
  • 1,164
  • 10
  • 18
  • No, there is no missing `}` in the code. Yes, there is a problem with that line -- which I pointed out 20 minutes ago. – T.J. Crowder Jul 23 '15 at 16:48