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]
3 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]3 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
Case 2-2 Jack has a computer at home that he uses to access the Internet, store and edit personal photos, and create and edit do
bekas [8.4K]

Answer:

Check button under error checking

Explanation:

Under the Tools tab there are two options:

Error checking and Optimize and defragment drive option.

clicking the check button with administrative permission under error checking option will examine the hard drive for errors.

3 0
2 years ago
It takes Mike 18 minutes to finish reading 4 pages of a book. How long would it take for him to finish 30 pages ?​
miss Akunina [59]

Answer:

135 minutes or and 2 hrs and 15 minutes

6 0
3 years ago
1. What are the two main functions of an operating system?
sesenic [268]

Answer:

(1) manage the computer's resources, such as the central processing unit, memory, disk drives, and printers, (2) establish a user interface, and (3) execute and provide services for applications software.

8 0
2 years ago
2.4 Code Practice: Question 2
klasskru [66]

num = float(input("Enter a number: "))

num1 = int(num)

print(num - num1)

I hope this helps!

8 0
2 years ago
What is malware? What are some signs that malware may be impacting the performance of your computer? How can you avoid malware?
Anni [7]

Answer:

Malware is a type of software that is specifically designed to disrupt, damage, or gain unauthorized access to a computer system. Malware can be spread through email attachments, online advertisements, websites, and other methods.

Some signs that malware may be impacting the performance of your computer include:

  • Your computer is running more slowly than usual
  • Your computer crashes frequently
  • Your computer has pop-up ads or other unwanted behavior
  • Your default homepage or search engine has changed without your permission
  • You see new icons or programs on your desktop that you didn't install

To avoid malware, you should be cautious when browsing the internet and avoid visiting suspicious websites. You should also avoid opening email attachments from unknown senders, and be wary of online advertisements. You can also protect your computer by using antivirus software and keeping it up to date.

3 0
1 year ago
Other questions:
  • If reading or writing a cache line of size 64 bytes to Flash requires 2.56 μJ and DRAM requires 0.5 nJ, and if idle power consum
    9·1 answer
  • The material of this section assumes that search keys are unique. However, only small modifications are needed to allow the tech
    7·1 answer
  • What is a example of blockchain
    8·1 answer
  • How many people on here are doing edmentum online
    11·1 answer
  • a. Daily Life Magazine wants an analysis of the demographic characteristics of its readers. The marketing department has collect
    13·1 answer
  • Write programs in python to display “Valid Voter”. (condition : age of person should be
    15·1 answer
  • Ethan wants to change the font in his document. He should _____.
    8·1 answer
  • Besides your computer, where else can you find and use an operating system?
    11·1 answer
  • Why do meteorologists use data such as temperature, wind speed, and air
    9·1 answer
  • What type of malware is best known for carrying other malware as a payload?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!