Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedCan 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Publishing With Filemaker Pro On The Web

Authors: Maria Langer

1st Edition

0201696657, 978-0201696653

More Books

Students also viewed these Databases questions

Question

Construct a derivation of 021222 in the grammar given in Example 7.

Answered: 1 week ago