0

This is a short part of my code. Im not sure why the code isn't print anything for equipment. It skips to "Does it have a whiteboard?(Y/n):". I don't think it is reading the input. What am i doing wrong here? (it reads everything else fine , I checked it)

switch(commands)
        {
        case "a":
            System.out.println("Please enter room number:");
            int roomNum = input.nextInt();
            System.out.println("Please enter number of seats:");
            int numSeat = input.nextInt();
            System.out.println("Please enter AV Equipment (separated by commas):");
            String equipment = input.nextLine();
            System.out.println(equipment);
            boolean hasWhiteboard;
            boolean hasChalkboard;
                input.nextLine();   
            System.out.println("Does it have a whiteboard?(Y/n):");
  • Yep i see, i needed an input.nextLine() after reading numSeat. whats the reason behind this ? – jackie chen Nov 16 '16 at 03:27
  • See the answers of [Scanner is skipping nextLine() after using next(), nextInt() or other nextFoo() methods](//stackoverflow.com/q/13102045), they explains that. – Tom Nov 16 '16 at 03:36

0 Answers0