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) {](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f31412e9832_41866f3141296f92.jpg)
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
Get step-by-step solutions from verified subject matter experts
