In Java Sound power level is expressed in decibels. A decibel is 10 x log10(picoWatts), where a picoWatt is 10-12 Watts. To determine the acoustical power level produced by the combination of two sound sources, we do the following: 1. Convert each decibel level into picoWatts, using the formula, picoWatts = 10(decibels / 10) 2. Add the picoWatt powers. 3. Convert the sum back into decibels. Using good style, create a class called Decibels. In the main method, declare two component decibel values, dB1 and dB1, both double variables. Also declare a combined decibel value, combinedDB. Prompt for and input the two component decibel values. Then use the above formulas and Math’s pow method and Math’s log10 method to compute the combined sound power level. Enter first decibel level: 63 Enter second decibel level: 65 Combination decibel level = 67.1244260279434 dB import java.util.Scanner; public class Decibels { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); double dB1, dB2; double combinedDB; System.out.print("Enter first decibel level: "); dB1 = stdIn.nextDouble(); System.out.print("Enter second decibel level: "); dB2 = stdIn.nextDouble(); // your code System.out.println( "Combination decibel level = " + combinedDB + " dB"); } // end main } // end class Decibels
In Java
Sound power level is expressed in decibels. A decibel is 10 x log10(picoWatts),
where a picoWatt is 10-12 Watts. To determine the acoustical power level
produced by the combination of two sound sources, we do the following:
1. Convert each decibel level into picoWatts, using the formula, picoWatts =
10(decibels / 10)
2. Add the picoWatt powers.
3. Convert the sum back into decibels.
Using good style, create a class called Decibels. In the main method, declare two
component decibel values, dB1 and dB1, both double variables. Also declare a
combined decibel value, combinedDB. Prompt for and input the two component
decibel values. Then use the above formulas and Math’s pow method and Math’s
log10 method to compute the combined sound power level.
Enter first decibel level: 63
Enter second decibel level: 65
Combination decibel level = 67.1244260279434 dB
import java.util.Scanner;
public class Decibels
{
public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
double dB1, dB2;
double combinedDB;
System.out.print("Enter first decibel level: ");
dB1 = stdIn.nextDouble();
System.out.print("Enter second decibel level: ");
dB2 = stdIn.nextDouble();
// your code
System.out.println(
"Combination decibel level = " + combinedDB + " dB");
} // end main
} // end class Decibels
Step by step
Solved in 4 steps with 2 images