Question

In: Computer Science

The following table shows the approximate speed of sound in air, water, and steel:

The following table shows the approximate speed of sound in air, water, and steel:

Medium Speed

Air 1,100 feet per second

Water 4,900 feet per second

Steel 16,400 feet per second

In Java, write a program that asks the user to enter “air”, “water”, or “steel”, and the distance that a sound wave will travel in the medium. The program should then display the amount of

time it will take.

You can calculate the amount of time it takes sound to travel in air with the following formula:

Time = Distance / 1,100

You can calculate the amount of time it takes sound to travel in water with the following formula:

Time = Distance / 4,900

You can calculate the amount of time it takes sound to travel in steel with the following formula:

Time = Distance / 16,400

Solutions

Expert Solution

import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] s)
{

String medium;
double distance;
double time;

Scanner choice = new Scanner(System.in);
System.out.println("Enter one of the following: air, water, or steel: ");
medium = choice.next(); // 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 = choice.nextDouble(); // 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.");   
}

}

}


Related Solutions

The following table shows the approximate speed of sound in air,water, and steel:MediumSpeed...
The following table shows the approximate speed of sound in air, water, and steel:MediumSpeedAir1,100 feet per secondWater4,900 feet per secondSteel16,400 feet per secondWrite a program that asks the user to enter “air”, “water”, or “steel”, and the distance that a sound wave will travel in the medium. The program should then display the amount of time it will take. You can calculate the amount of time it takes sound to travel in air with the following formula:Time=Distance/1,100Time=Distance/1,100You can calculate the...
The speed of sound in water is _____ than the speed of sound in air because _____.
The speed of sound in water is _____ than the speed of sound in air because _____. (a) Faster; water is much harder to compress (b) Faster; water is much more dense (c) Slower; water is much easier to compress (d) Slower; water is much less dense (e) Equal; the two fluids are at the same pressure
The following table shows the approximate number of males of Hispanic origin employed in the United...
The following table shows the approximate number of males of Hispanic origin employed in the United States in a certain year, broken down by age group. Age 15-24.9 25-54.9 55-64.9 Employment (thousands) 29,000 17,000 3,700 (a) Use the rounded midpoints of the given measurement classes to compute the expected value and the standard deviation of the age X of a male Hispanic worker in the United States. (Round all probabilities and intermediate calculations to two decimal places.) expected value yrs...
In this experiment, we have claimed to measure the speed of sound in air. To do...
In this experiment, we have claimed to measure the speed of sound in air. To do this, we have used an audible frequency sweep. Why can we claim that the speed of sound will be the same over the bandwidth of the sweep? Is this assertion justified based on your results from experiment 2? Hint: Consider how sound (longitudinal pressure waves) propagate in a medium. (5 pts)
The following table shows the approximate numbers of school goers in the United States (residents who...
The following table shows the approximate numbers of school goers in the United States (residents who attended some educational institution) in 1998, broken down by age group. Age 3−6.9 7−12.9 13−16.9 17−22.9 23−26.9 27−42.9 Population (millions) 8 22 15 13 3 5 Use the rounded midpoints of the given measurement classes to compute the probability P distribution of the age X of a school goer. (Round probabilities to four decimal places.) Age 5 10 15 20 25 35 P(X =...
Ultrasound probe emitting sound with wave length of 70 mm in air (sound speed 343 m/s)...
Ultrasound probe emitting sound with wave length of 70 mm in air (sound speed 343 m/s) is used for probing a muscle tissue (sound speed 1500 m/s). What are the smallest features in air and the muscle tissue that can be seen with this device?
The following table shows the approximate value of exports and imports for the United States from 1983 through 1987.
Imports, exports, and the trade balance The following table shows the approximate value of exports and imports for the United States from 1983 through 1987. Complete the table by calculating the surplus or deficit both in absolute (dollar) terms and as a percentage of GOP. If necessary, round your answers to the nearest hundredth. Between 1984 and 1985, the _______  _______ In dollar terms and _______ as a percentage of GOR.
The following table shows the approximate value of exports and imports for the United States from 1983 through 1987.
Imports, exports, and the trade balance The following table shows the approximate value of exports and imports for the United States from 1983 through 1987. Complete the table by calculating the surplus or deficit both in absolute (dollar) terms and as a percentage of GDP. If necessary, round your answers to the nearest hundredth. Source: "Income, Expenditures, Poverty, & Wealth: Gross Domestic Product (GDP)," United States Census Bureau, United States Department of Commerce, last modified September 2011, accessed June 10, 2013, https://www.census.gov/library/publications/2011/compendia/statab/131ed/income-expenditures-poverty-wealth.html. Between 1984...
a) Kinetic theory. The speed of sound in the air is 330 m/s under standard conditions...
a) Kinetic theory. The speed of sound in the air is 330 m/s under standard conditions of temperature and pressure (273 K and 1 atm). Since the size of a molecule is much smaller than the average distance between the molecules, this number provides an estimate of the order of magnitude of the molecular media velocity. Consider a cubic meter of air and concentrate it on a N2 molecule that travels in the x direction at 330 m / s....
The following table shows the Brinell hardness numbers of 20 individual steel fasteners. The testing process...
The following table shows the Brinell hardness numbers of 20 individual steel fasteners. The testing process dents the parts so that they cannot be used for their intended purpose. Construct the individual (X) and MR-chart based on two successive observations. Specification limits are 32 ± 7. Sample Brinell Sample Brinell Hardness Hardness 1 36.3 11 29.4 2 28.6 12 35.2 3 32.5 13 37.7 4 38.7 14 27.5 5 35.4 15 28.4 6 27.3 16 33.6 7 37.2 17 28.5...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT