0

Here is a simple question where you have to take an int and an string as an input and return the int input multiplied by 2 and string input as it is. Im giving the inputs correctly even then it is giving the same errors

   import java.util.*;
         class TestClass {
                    public static void main(String args[] )  {

                     Scanner scan = new Scanner(System.in);
                     int x = scan.nextInt();
                     String y = scan.nextLine();
                      x = x * 2;
                      System.out.println(x);
                       System.out.println(y);
                                                           }
                         }
  • Possible duplicate of [Scanner is skipping nextLine() after using next() or nextFoo()?](https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-or-nextfoo) – JonK Jun 20 '19 at 12:59

1 Answers1

-1
package codechef;

import java.util.*;

class HackerearthProblem {
    public static void main(String args[]) {

        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        String y = scan.next();
        x = x * 2;
        System.out.println(x);
        System.out.println(y);
    }
}
Nitin Zadage
  • 524
  • 6
  • 21
Kundan
  • 169
  • 1
  • 5