
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question

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

arrow_forward
switch
The switch
statement allows us to execute a block of code among many alternatives.
switch (expression) {
case value1:
// code to be executed if
// expression is equal to value1
break;
case value2:
// code to be executed if
// expression is equal to value2
break;
...
...
default:
// default statements
}
The expression is evaluated once and compared with the values of each case label.
- If there is a match, the corresponding code after the matching case label is executed.
For example, if the value of the expression is equal to value2, the code aftercase value2:
is executed. - If there is no match, the code after
default:
is executed.
Note: We can do the same functionality using the Java if...else...if ladder. However, the syntax of the switch statement is cleaner and much easier to read and write.
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
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
- Computer Science Part C: Interactive Driver Program Write an interactive driver program that creates a Course object (you can decide the name and roster/waitlist sizes). Then, use a loop to interactively allow the user to add students, drop students, or view the course. Display the result (success/failure) of each add/drop.arrow_forwardThe Step Out function executes one source line of a program. If the line is a function call it executes the function and returns control to the main window to the caller to the assignee to the debuggerarrow_forwardDrawa structured flowchart , C++, write pseudocode that describes the process of guessing a number between 1 and 100. After each guess, the player is told that the guess is too high or too low. The process continues until the player guesses the correct number. Pick a number and have a fellow student try to guess it following your instructions.arrow_forward
- C++ program Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number of organisms, their average daily population increase (as a percentage of current population), and the number of days they will multiply. A loop should display the size of the population for each day.arrow_forwardA first block statement is invalid beyond a specified time.arrow_forward1) Rolling dice simulator in C language Requirement: . Write a program that stimulate rolling dice. When the program runs it will randomly choose a number between 1 and 6 . . The program will print what the number is . It should then ask you if you'd like to roll again . Do it C , and also use while looparrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education