rogram requires 2 java files, the testing program should use a switch

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

program requires 2 java files, the testing program should use a switch

9. 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
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 addi-
tion, 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 in 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
will then display the amount of time it will take. Check that the user has selected one of
the available choices from the menu.
program
ling Roints
Transcribed Image Text:9. 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 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 addi- tion, 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 in 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 will then display the amount of time it will take. Check that the user has selected one of the available choices from the menu. program ling Roints
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage