Question: import java.util.Scanner; public class TheSpeedOfSound { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print(Enter one of the following: air, water, or

import java.util.Scanner;

public class TheSpeedOfSound {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter one of the following: air, water, or steel: "); String material = scanner.nextLine(); //read the data into doubles so the division will also gives double values double distance; double seconds; if (material.equalsIgnoreCase("air")) { System.out.print("Enter the distance the sound wave will travel: "); distance = scanner.nextDouble(); seconds = distance / 1100; System.out.println("It will take " + seconds + " seconds."); } else if (material.equalsIgnoreCase("water")) { System.out.print("Enter the distance the sound wave will travel: "); distance = scanner.nextDouble(); seconds = distance / 4900; System.out.println("It will take " + seconds + " seconds."); } else if (material.equalsIgnoreCase("stell")) { System.out.print("Enter the distance the sound wave will travel: "); distance = scanner.nextDouble(); seconds = distance / 16400; System.out.println("It will take " + seconds + " seconds."); } else { System.out.println("Sorry, you must enter air, water, or steel."); } } }

getting below error with this code, can anyone pls help me to resolve this

import java.util.Scanner; public class TheSpeedOfSound { public static void main(String[] args) {

Comparing Expected and Actual Output Suggestion: mouse over the highlighted areas to see the specific comparison of erroneous actual output to the expected correct output. Expected Output: Enter one of the following: -air, water, or steel:- Enter the distance-the-sound-wave-will-travel:-. It will take 1.8292682926829268E-4-seconds.. Actual Output: Enter one of the following: -air, water, or steel: Sorry, you - must-enter-air, water, .or-steel.- LEGEND OF SPECIAL SYMBOLS: Symbol Meaning Space Char Newline (in) Tab (t) Carriage Return ( )

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!