Computer Applications
Give the output of the following:
- Math.floor (-4.7)
- Math.ceil(3.4) + Math.pow(2, 3)
Java
Java Math Lib Methods
ICSE 2018
32 Likes
Answer
- -5.0
- 12.0
Math.floor method returns the largest double value that is less than or equal to the argument and is equal to a mathematical integer. As -5.0 is the largest mathematical integer less than -4.7 so it is the output. Note that -4.7 is a negative number so the largest integer less than -4.7 is -5.0 and not -4.0.
Math.ceil(3.4) gives 4.0 and Math.pow(2,3) gives 8.0. So the output is 4.0 + 8.0 = 12.0.
Answered By
15 Likes
Related Questions
Which of the following mathematical methods returns only an integer?
- Math.ceil(n)
- Math.sqrt(n)
- Math.floor(n)
- Math.round(n)
A Student executes the given program segment and it results in 1.0, irrespective of the value of n. State the type of the error, write the correct statement:
void solve(int n) { double power=Math.pow(n, 2/3); System.out.println(power); }Write a Java expression for the following:
|x2 + 2xy|Write the java statement for:
Sum of a raised to b and cuberoot of c