3.12. (Part2) The Speed Of Sound - Java

Words
176
Reading
1 min
Listen
Play
10y

Starting out with Java: From control structures through objects

Chapter 3

Programming Challenges

12. The Speed of Sound 

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 

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

Gaddis, Tony (2015-05-29). Starting Out with Java: From Control Structures through Objects (Page 187). Pearson Education. 

Kindle Edition.

Happy Steeming Everyone! :)

3.12. (Part2) The Speed Of Sound - Java | Ecency