The speed of sound - The following table shows the approximate speed of sound in
ID: 3675978 • Letter: T
Question
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 program(Pseudo code) that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the number of seconds the sound will travel in the selected medium. The program(pseudo code) should then display the distance the sound will travel.
Scoonds, speed Call showSaund(manySeconds speed) Call Cal Set speed 1 100 True Set speed 4900 Falsc Set speed = 16400 Ref selecton) End Select medium for sound travel. 2. Weter 3. Stnel 4. End the Program. Enter your selection Input selection selection 1 OR selection4 True Display That is an nvaid selecion Input selection Enter 1, 2, 3, Or 4. False End MaduleExplanation / Answer
You can calculate the amount of time it takes sound to travel in air with the following formula:
Time = Distance / 1100
You can calculate the amount of time it takes sound to travel in water with the following formula:
Time = Distance / 4900
You can calculate the amount of time it takes sound to travel in steel with the following formula:
Time = Distance / 16400
public class Sound
{
public static void main(String[ ] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter air, water, steel: ");
String input;
input = keyboard.nextLine();
System.out.print("Enter distance: ");
double distance;
distance = keyboard.nextDouble();
double time;
if (input.equals("air"))
{
time = (distance / 1100);
System.out.println("The total time traveled is " + time +);
else if (input.equals("water"))
{
time = (distance / 4900);
System.out.println("The total time traveled is " + time +);
}
else if (input.equals("steel"))
{
time = (distance / 16400);
System.out.println("The total time traveled is " + time +);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.