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
Wite 3 names of computers used in 1st generation of computers?
enyata [817]
Here are some of the computers used in the first generation of computers:
ENIAC
EDVAC
UNIVAC
IBM-701
IBM-650
These are some of the first computers ever that led to today's computers.
5 0
2 years ago
I made a fish emoji what do you think >{'_'}< should I change anything
Anvisha [2.4K]

Answer: It is beautiful

Explanation:

3 0
2 years ago
Read 2 more answers
Database users who access data only through application programs are called
Alex777 [14]
A. casual users hope this helps
7 0
3 years ago
What would you enter at the command prompt to start a new bourne again shell session?
butalik [34]

The answer is bash . The bash command opens a Bourne-again sheel (bash) session. It is the standard shell used in most Linux computers and it uses commands similar to a UNIX shell. Bash includes features such as:

1) Command completion when pressing the tab key.

2) Command history.

3) Improved arithmetic functions.

6 0
3 years ago
Calculate the denary value of the 8-bit number 01101001. Explain how you worked it out
Julli [10]

Answer:

105

Explanation:

explanation is in the picture..

5 0
2 years ago
Other questions:
  • Name five services available at banks.
    7·1 answer
  • A general rule for adding text to a slide is ____.
    7·2 answers
  • Blank are back and forth movement of matter that create sound​
    15·1 answer
  • Which window allows you to view and change your computer's system information and settings?
    9·2 answers
  • A package delivery company or a cell phone company wouldn't go far if it could not deliver products smoothly and reliably. This
    15·1 answer
  • A jackhammer uses pressurized gas to transmit force to the hammer bit. What type of mechanical system is it?
    13·1 answer
  • Last bittttt of points
    8·1 answer
  • Explain the major innavotions made from the establishment of abacus​
    8·1 answer
  • Select the correct answer.
    10·1 answer
  • What are the benefits of computer literacy?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!