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
When working in Excel Online, what is it called when you drag the fill handle down to copy data?
SVEN [57.7K]
It’s called drag fill
5 0
3 years ago
Read 2 more answers
What does gps stand for ?
frutty [35]
GPS stands for Global Positioning System
3 0
3 years ago
Read 2 more answers
what is the name of the program that enables the device and operating system to communicate with each other?
Fittoniya [83]

Answer:

Explain Operating System working: OS works as an intermediate between the user and computer. It helps the user to communicate with the computer without knowing how to speak the computer's language. The kernel is the central component of a computer operating systems.

Explanation:

3 0
2 years ago
Write a C++ program that consist
pshichka [43]

Answer:

Explanation:

The object-oriented paradigm; The compilation process Comments; Library inclusions; Program-level definitions; Function prototypes;

The main program; Function definitions Naming conventions; Local and global variables; The concept of a data type;

Integer types; Floating-point types; Text types; Boolean type; Simple input and

output Precedence and associativity; Mixing types in an expression; Integer division and

the remainder operator; Type casts; The assignment operator; Increment and

decrement operators; Boolean operators

7 0
3 years ago
Word processing programs, spreadsheet programs, email programs, web browsers, and game programs belong to what category of softw
liq [111]

Answer:  They belong to a category of software known as Application program

Explanation: an application program is a computer program that is designed and implemented to carry out a specific task or for a specific purpose. Spreadsheet programs for instance are designed and implemented to carry out mathematical calculations, gaming programs for recreation, web programs for connecting to the internet and email programs for sending and receiving of emails.

6 0
2 years ago
Read 2 more answers
Other questions:
  • 1) If a client requests timestamping every two minutes, how would it look? a) [00:02:00] b) [00:06:00] c) (00:04:00)
    15·2 answers
  • What is the full form of bcc please tell​
    15·2 answers
  • Describe some ways that you personally use information technologies differently than you did just a few years ago
    11·1 answer
  • Implement a Python function with the signature Transfer(S, T) that transfers all elements from the ArrayStack instance S onto th
    13·1 answer
  • Quinton is having trouble learning Spanish because he keeps reverting back to the grammatical structures of his native English l
    6·1 answer
  • Which components exist in the contextual tab for tables called Design? Check all that apply.
    15·2 answers
  • To provide for unobtrusive validation, you can install the ____________________ package for unobtrusive validation.
    11·1 answer
  • Write a program. in QBAsSIC
    13·1 answer
  • I'm having trouble with an assignment of mine. I'm making a text based adventure game for extra credit in my class and I'm stuck
    12·1 answer
  • Which describes the Paradox of Automation?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!