1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Thepotemich [5.8K]
3 years ago
9

The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per se

cond) for air, water and steel:
air: 1,100 feet per second

water: 4,900 feet per second

steel: 16,400 feet per second


Write a program that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the distance a sound wave will travel in the selected medium. The program will then display the amount of time it will take.

Menu. The menu should look exactly like this:

Select a medium:
1. Air
2. Water
3. Steel

Computers and Technology
1 answer:
german3 years ago
8 0

Answer:

The Java Program for the given problem is as below. Directly copy the code and run it on your machine.

Explanation:

Refer the Screenshots attached for the output.

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class TheSpeedOfSound {

public static void main(String[] s)

{

String medium;

double distance;

double time;

try{

BufferedReader choice = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter one of the following: air, water, or steel: ");

medium = choice.readLine(); // reading input i.e. air, water or steel

//check for air water and steel

if (medium.equalsIgnoreCase("air") || medium.equalsIgnoreCase("water") || medium.equalsIgnoreCase("steel")){

System.out.println("Enter the distance the sound wave will travel: ");

distance = Double.parseDouble(choice.readLine()); // read distance value if it is air water or steel

switch (medium)

{

//if medium is air

case "air":

time = distance/1100;

System.out.print("It will take " + time + " seconds.");

break;

//if medium is water

case "water":

time = distance/4900;

System.out.print("It will take " + time + " seconds.");

break;

//if medium is steel

case "steel":

time = distance/16400;

System.out.print("It will take " + time + " seconds.");

break;

}

}

else{

System.out.print("Sorry, you must enter air, water, or steel.");  

}

}

catch(Exception e){

e.printStackTrace();

}

}

}

You might be interested in
Need help with this file and due today!!
BARSIC [14]
I can’t see the picture
7 0
3 years ago
How can a chart help to display your data? How does one choose the best type of chart to use, and how does one ensure that he or
Kay [80]
I think this should be under math. So let's say that you have tons of data and you need to sort it. A chart will help to graph that data in an organized formation.
6 0
3 years ago
Which of the following tasks could be implemented as a filter using only a constant amount of memory (e.g., a couple of int or d
Nesterboy [21]

Answer:

Print the sum of the squares of the n numbers

Print the percentage of numbers greater than the average of the n numbers

Print the median f n numbers

Explanation:

The computer programs have different configurations based on the assigned tasks. The constant amount of memory is used by the cache. This is the new technology in the computer software which consumes only small amount of memory and activates once the task is assigned to it.

4 0
3 years ago
Plz help meeeeee QUICKLY!!! WORTH 15 POINTS!
Lady bird [3.3K]

Answer:

Im pretty sure Domain name system but dont trust me

Explanation:

8 0
3 years ago
If a friend changes the password on your phone how do you get into it if you dont know the password
kotegsom [21]
Ask your friend to tell you the password
3 0
3 years ago
Other questions:
  • A cell reference that has only one $ is referred to as a(n) ____ cell reference. alternative mixed relative absolute
    7·1 answer
  • The Cisco IOS automatically modifies the dead interval when the _____ interval is changed. (Points : 2) hello
    13·1 answer
  • How was windows 3 installed on a pc?
    11·1 answer
  • darren wants to substitute every occurence of the word bulky in his spreadsheet with the word strong. which of these options sho
    9·2 answers
  • Clunker Motors Inc. is recalling all vehicles in its Extravagant line from model years 1999-2002 as well all vehicles in its Guz
    15·1 answer
  • What are the features of Cobol language that make it suitable for programming business applications.
    6·1 answer
  • Cual es la definición de grouded?​
    7·1 answer
  • Name two materials that we can burn in order to get energy from biomass
    9·1 answer
  • Commercial technical data and commercial software:_________.
    11·1 answer
  • What is computer software​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!