In: Computer Science
In java. Determine the value of each of the following expressions. (Format your answer with two decimal places.) a. Math.abs(-4) b. Math.abs(10.8) c. Math.abs(-2.5) d. Math.pow(3.2, 2) e. Math.pow(2.5, 3) f. Math.sqrt(25.0) g. Math.sqrt(6.25) h. Math.pow(3.0, 4.0) / Math.abs(-9) i. Math.floor(28.95) j. Math.ceil(35.2)
Source Code:
import java.lang.Math;
class ex
{
public static void main(String[] args) {
System.out.printf("Math.abs(-4)=%d\n",Math.abs(-4));
System.out.printf("Math.abs(10.8)=%.2f\n",Math.abs(10.8));
System.out.printf("Math.abs(-2.5)=%.2f\n",Math.abs(-2.5));
System.out.printf("Math.pow(3.2,
2=%.2f\n",Math.pow(3.2,2));
System.out.printf("Math.pow(2.5,
3)=%.2f\n",Math.pow(2.5,3));
System.out.printf("Math.sqrt(25.0)=%.2f\n",Math.sqrt(25.0));
System.out.printf("Math.sqrt(6.25)=%.2f\n",Math.sqrt(6.25));
System.out.printf("Math.pow(3.0,
4.0)/Math.abs(-9)=%.2f\n",Math.pow(3.0,4.0)/Math.abs(-9));
System.out.printf("Math.floor(28.95)=%.2f\n",Math.floor(28.95));
System.out.printf("Math.ceil(35.2)=%.2f\n",Math.ceil(35.2));
}
}
Sample input and
output: