I can't find the error in my code. It works when I move the commands around and ask for two string inputs in a row, but when I ask for a string then an integer then a string again, I get no response from the keyboard for the second string.
I have cut and paste the String option = scan.nextLine(); to different locations. it works before the integer input but not after. I see the prompt in the command window to type a user input but when I hit the keys on the keyboard nothing happens
import java.util.Scanner;
public class Assignment6 {
public static void main(String[] args) {
// Create scanner
Scanner scan = new Scanner(System.in);
// variables
int year;
int numQuestions;
String name;
// Create Geek
System.out.println("Please enter the geeks name: ");
name = scan.nextLine();
System.out.println("Please enter the number of questions the geek answers: ");
numQuestions = scan.nextInt();
System.out.println("\nPlease enter a command or type: ");
String option = scan.nextLine();
}
}
Using eclipse and java