1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
garik1379 [7]
4 years ago
5

The Speed of Sound (Java Project. Please make it easy to understand. I'm a beginner at this. I believe we are supposed to use a

switch or if/else) The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per second) for air, water and steel: air: 1,100 feet per second water: 4,900 feet per second steel: 16,400 feet per second Write a program class TheSpeedOfSound 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 watert 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,400the user should enter an "A" for "air", a "W" for "water, and an "S" for steel and the distance.use the switch statement as part of your solution.display your answer using the printf statement.
Computers and Technology
1 answer:
Ilya [14]4 years ago
6 0

Answer:

The program of this question can be given as:

Program:

//import pacakge for user input.

import java.util.Scanner;

//define class  

public class SpeedofSound              

{

  public static void main(String a[]) //define main function

  {  

      //define variable.

      String medium;                            

      double distance,time=0;

      //creating Scanner class object for input from user.

      Scanner s=new Scanner(System.in);  

      //print message.

      System.out.printf("Enter medium(air,water or steel) : ");

      medium=s.nextLine();  //taking input.

      //print message.

      System.out.printf("Enter the distance that the sound will travel : ");

      distance=s.nextDouble(); //taking input.

      switch(medium) //checking condtion between range.

      {

          case "air":

                  time=distance/1100;         //apply formula

                  break;

          case "water":

                  time=distance/4900;            //apply formula

                  break;

          case "steel":

                  time=distance/16400;            //apply formula

                  break;

          default:

                  System.out.printf("Sorry, you must enter air,water or steel"); //error for invalid input of medium

                  System.exit(0);

      }

      System.out.printf("It take "+time+" seconds"); //print final answer.

  }

}

Output:

Enter medium(air,water or steel) : air

Enter the distance that the sound will travel : 200

It take 0.18181818181818182 seconds

Explanation:

In this program first, we import packages for user input. Then we declare the class in the class we declare all the variables and then we create the scanner class object. It is used for taking input from the user. Then we use the switch statement It is used for condition. It works between the ranges. In the switch statement, we apply all the formula that is given in the question. and at the last, we print the output using printf function in java.

You might be interested in
Which of the following software programs provides for e-mail communication?
Mila [183]
Outlook is a software program that provides for e-mail communication
8 0
3 years ago
Why laptop computer is called micro computer?​
Eduardwww [97]

Answer:

A lot top is a microcomputer because Michael computer has all the devices that you can use

3 0
3 years ago
In which decade did cell phones become available to the public?
JulijaS [17]

Answer:

1980s

Explanation:

Source:

https://www.cbc.ca/news/technology/5-major-moments-in-cellphone-history-1.1407352

6 0
3 years ago
Maya wrote a program and forgot to put the steps in the correct order. Which step does Maya need to review? Pattern following Pl
Drupady [299]

Answer:

Sequencing

Explanation:

7 0
3 years ago
Read 2 more answers
Countdown until matching digits Write a program that takes in an integer in the range 11-100 as input. The output is a countdown
Dovator [93]

Answer:

The program in C is as follows:

#include <stdio.h>

int main(){

   int n;

   scanf("%d", &n);

   if(n<11 || n>100){

       printf("Input must be between 11 - 100");    }

   else{

       while(n%11 != 0){

           printf("%d ", n);

           n--;        }

       printf("%d ", n);    }

   return 0;

}

Explanation:

The existing template can not be used. So, I design the program from scratch.

This declares the number n, as integer

   int n;

This gets input for n

   scanf("%d", &n);

This checks if input is within range (11 - 100, inclusive)

   if(n<11 || n>100){

The following prompt is printed if the number is out of range

       printf("Input must be between 11 - 100");    }

   else{

If input is within range, the countdown is printed

       while(n%11 != 0){ ----This checks if the digits are identical using modulus 11

Print the digit

           printf("%d ", n);

Decrement by 1

           n--;        }

This prints the last expected output

       printf("%d ", n);    }

4 0
3 years ago
Other questions:
  • Audacity is _________ program that is free to download and is used by tens of millions of people worldwide.
    9·2 answers
  • Mark is looking for a position in the IT field that best matches his qualifications. He has an associate degree in the field and
    6·1 answer
  • Marie uses DHTML to create a website for her college. How is DHTML more helpful than HTML?
    13·2 answers
  • In client server network, there is no central server //// true or false​
    8·1 answer
  • Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any ot
    10·1 answer
  • UserInp = input("Did you like the story?")
    7·1 answer
  • F. Practical Questions
    7·1 answer
  • What is wrong with line 3 ?
    11·1 answer
  • How to make classs constructer java.
    14·1 answer
  • Who invented Satellites? What purpose does it serve? How has it impacted society today?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!