Java Stdin and Stdout II

  • + 3 comments

    Here is it. It works for all the test cases The first - String s = sc.nextLine(); reads "\n" . Hence some of you got the error. and then second s=sc.nextLine(); reads the complete line

        Scanner sc = new Scanner(System.in) ;
        int i = sc.nextInt();
        double d = sc.nextDouble();
        String s = sc.nextLine();
        s=sc.nextLine();
         System.out.println("String: "+s);
         System.out.println("Double: "+d);
         System.out.println("Int: "+i);