Problem

The Speed of SoundThe following table shows the approximate speed of sound in air, water,...

The Speed of Sound

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

Medium

Speed

Air

1100 feet per second

Water

4900 feet per second

Steel

16,400 feet per second

Design a class that stores in a distance field the distance, in feet, traveled by a sound wave. The class should have the appropriate accessor and mutator methods for this field. In addition, the class should have the following methods:

• getSpeedInAir. This method should return the number of seconds it would take a sound wave to travel, in air, the distance stored in the distance field. The formula to calculate the amount of time it will take the sound wave to travel the specified distance in air is:

Time = distance/1100

• getSpeedInWater. This method should return the number of seconds it would take a sound wave to travel, in water, the distance stored hi the distance field. The formula to calculate the amount of time it will take the sound wave to travel the specified distance in water is:

Time = distance/4900

• getSpeedInSteel. This method should return the number of seconds it would take a sound wave to travel, in steel, the distance stored in the distance field. The formula to calculate the amount of time it will take the sound wave to travel the specified distance in air is:

Time = distance/16400

Write a program to demonstrate the class. The program should display a menu allowing the user to select air, water, or steel. Once 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. Check that the user has selected one of the available choices from the menu.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT