• + 2 comments

    My code is working properly in Ecclipse but Hackerank gives below error. can anyone explain why?

    import java.io.; import java.util.; public class ScannerEx {

    public static void main(String[] args) {
        int i = 4;
        double d = 4.0;
        String s = "HackerRank ";
    
        Scanner scan = new Scanner(System.in);
        /* Declare second integer, double, and String variables. */
        int a;
        double b;
        String c;
    
    /* Read and save an integer, double, and String to your variables.*/
     a=scan.nextInt();
     Scanner scan2=new Scanner(System.in);
     b=scan2.nextDouble();
     Scanner scan3=new Scanner(System.in);
     c=scan3.next();
    
    /* Print the sum of both integer variables on a new line. */
        System.out.println(i+a);
    /* Print the sum of the double variables on a new line. */
        System.out.println(d+b);
    
    /* Concatenate and print the String variables on a new line; 
        the 's' variable above should be printed first. */
        System.out.println(s+c);
        scan.close();
    }
    

    }