Sound travels through air as a result of collisions between the molecules in the
ID: 3565016 • Letter: S
Question
Sound travels through air as a result of collisions between the molecules in the air. The temperature of the air affects the speed of the molecules, which in turn affects the speed of sound. The velocity of sound in dry air can be approximated by the formula: Velocity = 331.3 + 0.61 * Tc Where Tc is the temperature of the air in degree celsius and the velocity in meters/second. Write a program that allows the user to input a starting and an ending temperature. Within this temperature range, the program should output the temperature and the corresponding velocity in one-degree increments. For example, if the user entered 0 as the start temp and 2 as the end temp, then the program should output: At 0 degrees Celsius the velocity of sound is 331.3 m/s At 1 degrees Celsius the velocity of sound is 331.9m m/s At 2 degrees Celsius the velocity of sound is 332.5 m/s
Explanation / Answer
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class CalculateVelocity {
public static void main(String ar[]) throws Exception{
int startTemp,endTemp,Tc;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter start Temperature ");
startTemp = Integer.parseInt(br.readLine());
System.out.println("Enter End Temperature ");
endTemp = Integer.parseInt(br.readLine());
Tc= startTemp;
while(Tc<=endTemp)
{
System.out.println("Velocity at "+ Tc+"
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.