I run my code then I put in an integer, press enter, then I get an extra input space. In the extra input space I put in a number then I get the input space I want where it says "Write A Line". It only adds the numbers I put in the first input space and the extra input space. Please help. (P.S Sorry for code's format)
My Output: Write An Integer (put my input here) (put my input here) Write An Integer (put my input here)
I don't want that 2nd input option.
public static void main(String eth[]){
System.out.println("Write An Integer");
Scanner input = new Scanner(System.in);
if (input.hasNextInt()){
}
else System.out.println("Play By The Rules");
Scanner input1 = new Scanner(System.in);
int a = input1.nextInt();
{
System.out.println("Write An Integer");
Scanner input2 = new Scanner(System.in);
int b = input2.nextInt();
int answer = (a+b);
System.out.println(answer);
}
}
}