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
Which domain refers to the equipment and data an organization uses to support its IT infrastructure. It includes hardware, opera
vovikov84 [41]

Answer:

D. System/Application Domain

Explanation:

A system or application domain is used by an organization to supports its IT infrastructure, holding all the business critical mission system, applications and data. All the resources of the company are contained in this domain, and is accessible by a member.

LAN to WAN domain links the company's infrastructure or local area network to a wide area network or the internet. The WAN domain simply holds publicly the data of an organisation, while remote access domain is meant for a small group of workers in the office or working from home.

8 0
3 years ago
4
kupik [55]

Answer:

the answer is D Smart Object

5 0
3 years ago
Read 2 more answers
Write the half function. A function call and the functionprototype
EastWind [94]

Answer:

C code for half()

#include<stdio.h>

void half(float *pv);

int main()

{

float value=5.0;  //value is initialized  

printf ("Value before half: %4.1f\n", value); // Prints 5.0

half(&value);  // the function call takes the address of the variable.

printf("Value after half: %4.1f\n", value); // Prints 2.5

}

void half(float *pv) //In function definition pointer pv will hold the address of variable passed.

{

*pv=*pv/2;  //pointer value is accessed through * operator.

}

  • This method is called call-by-reference method.
  • Here when we call a function, we pass the address of the variable instead of passing the value of the variable.
  • The address of “value” is passed from the “half” function within main(), then in called “half” function we store the address in float pointer ‘pv.’ Now inside the half(),  we can manipulate the value pointed by pointer ‘pv’. That will reflect in the main().
  • Inside half() we write *pv=*pv/2, which means the value of variable pointed by ‘pv’ will be the half of its value, so after returning from half function value of variable “value” inside main will be 2.5.

Output:

Output is given as image.

3 0
3 years ago
Which careers have the highest minimum experience requirement?
Dafna11 [192]
(B) CIO, because they make $308,561 per year and it wouldn’t be A cause they only make $140,265 per year nor would C .
8 0
3 years ago
Consider the following statements regarding computer programs A - Variables can contain different values at different times.B -
jeka94

Answer:

The answer is: Only A is correct.

Explanation:

Variables in a program can assume different values at different times, and the program can then produce different results, depending on circumstances, so A is correct.

In a computer language, a reserved word (also known as a reserved identifier) is a word that cannot be used as an identifier, such as the name of a variable, function, or label – it is "reserved from use". This is a syntactic definition, and a reserved word may have no meaning. So, B is incorrect.

Hence, the answer is: Only A is correct.

6 0
2 years ago
Other questions:
  • Automotive engine cylinder heads can be made of what?
    7·1 answer
  • What do you call the process of translating statements written by a developer? What is the result of this process?
    6·1 answer
  • How to buy free big money computers that earn free money everydays?
    15·1 answer
  • Which of these is most closely associated with system control? (1 point) (Points : 1.5) boundary
    10·1 answer
  • If a code word is defined to be a sequence of different letters chosen from the 10 letters A, B, C, D, E, F, G, H, I, and J, wha
    15·1 answer
  • Two system administrators who work in two different buildings for the same company want to open a communication channel between
    8·1 answer
  • Anyone can help me please ?
    7·1 answer
  • Initialized the variable with the value 0
    11·2 answers
  • What is one way to process your thoughts about the information you are reading?
    15·1 answer
  • mary has access to certain resources because she is in the Research division of her company. She has access to other resources b
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!