in Education by
In Java, what will be the output of the following code and how? double x=2.9,y=2.5; (SOP is abbreviated form of System.out.println) SOP(Math.min(Math.floor(x),y)); SOP(Math.max(Math.ceil(x),y)); Explain how… Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Hey Mate! Here’s the solution: x = 2.9 and y = 2.5 Math.min( ) returns the minimum(or the smallest) number among the 2 numbers given(In this case, the numbers are Math.floor(2.9) and 2.5) . Math.max( ) returns the maximum(or the largest) number among the 2 numbers given(In this case, the numbers are Math.ceil(2.9) and 2.5). Math.floor( ) returns the number given by rounding it downwards. For example, Math.floor(3.2) returns 3.0 and Math.floor(5.6) returns 5.0. Math.ceil( ) can be called the opposite of Math.floor( ). It returns the number given by rounding it upwards. For example, Math.ceil(3.2) returns 4.0 and Math.ceil(5.6) returns 6.0 In the given question, Math.floor(x) will return 2.0 And the minimum among 2.0 and 2.5 is 2.0 and hence it gets displayed. Math.ceil(x) returns 3.0 and the maximum among 3.0 and 2.5 is 3.0 which gets displayed. So, the output should be as follows: 2.0 3.0 Hope it helps! And all the best for your exam!

Related questions

0 votes
    Math Functions: System.out.println (Moth floor (-0.48)]; System.out.println (Math ceil (-0.46)); System.out.println ... Hound (-8.5)); Select the correct answer from above options...
asked Dec 16, 2021 in Education by JackTerrance
0 votes
    double x=0.5; System.out.println(Math.rint(x)); ….Plzz give me the output… Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    import java.util.*; class hello{ System.out.println(Math.ceil(-28.23)); } IN THIS CODE JAVA COMPILER IS ... URGENT .PLEASE . Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    e)What will be the output of the following code? (2) x,y=4,8 z=x/y*y print(z) Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
0 votes
    What Is the output of the following:String a= Java is programming language \n developed by \t\'James Gosling\' ... ; Please Answer ASAP Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    int n=10;int res=(n–+10>–n×5)?++n:n++ System.Out.println(res+”,”+n); what is the output Select the correct answer from above options...
asked Dec 30, 2021 in Education by JackTerrance
0 votes
    class Modulus { public static void main(String args[]) { double a = 25.64; int b = 25; a = a % 10; b = b % 10; ... (a + + b); } } Select the correct answer from above options...
asked Dec 19, 2021 in Education by JackTerrance
0 votes
0 votes
    What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
0 votes
    (a) What will be the output of the following Python code? from math import factorial print (math.factorial (5) ... : print(factorial(5) Select the correct answer from above options...
asked Dec 17, 2021 in Education by JackTerrance
0 votes
    Eight persons A, B, C, D, N, X, Y and Z live in an eight story building, one on each floor but not ... floor numbers of A and N? Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
...