Question: Can you help me with this error? please explain to me why this would happen when I have a empty input, and doesn't come out

Can you help me with this error? please explain to me whyCan you help me with this error? please explain to me why this would happen when I have a empty input, and doesn't come out as saying "We're not sure who that is. We need to investigate further."? why would this come out? where is the problem?

14 7777777777777777777777777777777 80 COLUMNS WIDE 77777777777777777777777777777777 15 import java.util.Scanner; 16 public class Clue{ public static void main(String[] args) { Scanner scnr = new Scanner(System.in); System.out.println("Who was the murderer?"); String witness = scnr.next(); if (witness.equalsignoreCase("Amos")) { System.out.println("It was Amos with the candlestick!"); else if (witness.equalsignoreCase("Kevin")) { System.out.println("It was Kevin with the revolver!"); else if (witness.equalsIgnoreCase("Juan")) { System.out.println("It was Juan with the lead pipe!"); else { System.out.println("We're not sure who that is. We need to investigate further."); 36 } Develop mode Submit mode Run your program as often as you'd like, before submitting for grading. Below, type any needed input values in the first box, then click Run program and observe the program's output in the second box. Enter program input (optional) If your code requires input values, provide them here. Your program expects input Run program Input (from above) Clue.java (Your program) Output (shown below) Program output displayed here Who was the murderer? Exception in thread "main" java.util.NoSuchElementException at java.base/java.util.Scanner. throwFor (Scanner.java:937) at java.base/java.util.Scanner.next(Scanner.java: 1478) at clue.main(Clue.java:20)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!