Computer Science, asked by vaishalibachhav713, 3 months ago

Give the output of the following

double x=8.7, y=4.5;

System.out.println(Math.min(Math.floor(x),y));​

Answers

Answered by atrs7391
2

\textsf{\Large{\underline{\textbf{Snippet:}}}}

\texttt{double x=8.7, y=4.5;}

\texttt{System.out.println(Math.min(Math.floor(x),y));}

\textsf{\Large{\underline{\textbf{0utput:}}}}

\texttt{4.5}

\textsf{\Large{\underline{\textbf{About Functions in the Snippet:}}}}

\textsf{\large{{\textbf{Math.min():}}}}

\texttt{Returns the smaller of two double values.}

\texttt{That is, the result is the value closer to }\\

\texttt{negative infinity.}

\textsf{\large{{\textbf{Math.floor():}}}}

\texttt{Returns the largest (closest to positive infinity)}

\texttt{double value that is less than or equal to the}

\texttt{argument and is equal to a mathematical}

\texttt{integer.}

Answered by anindyaadhikari13
1

Required Answer:-

Given Cσde:

\tt double\ x=8.7,\ y=4.5;

\tt System.out.println(Math.min(Math.floor(x), y));

To Find:

  • Output (Java).

Output:

  • 4.5

Explanation:

  • Math.floor() function returns the lower integer for the given argument.
  • So, Math.floor(x) = Math.floor(8.7) = 8.0
  • Now, Math.min() function returns the minimum value of two numbers. Minimum of 8.0 and 4.5 is 4.5. Thus, the output is 4.5.

•••♪

Similar questions