blahblah7956 blahblah7956
  • 06-01-2021
  • Computers and Technology
contestada

Rewrite the following condition to avoid a possible arithmetic exception:

if (Math.sqrt(x) < 3 && x > 7)

Respuesta :

IfeanyiEze8899 IfeanyiEze8899
  • 06-01-2021

Answer:

if (x > 7 && Math.sqrt(x) < 3)

Explanation:

The previous condition checks if the square root of x is less than 3, but this would raise an error if x is a value equal to or less than 0.

So, the condition checks for the value of x before evaluating the square root after the AND operation to prevent an arithmetic exception.

Answer Link

Otras preguntas

A mine extracts 2 metric tons of coal in an hour. The mine uses 1/4 ton of the extracted coal every hour to generate electricity for the mine and sells the rest
what are the steps to write 36/10 as a decimal
what is the deciml equivalent to 1/2.
where does y=2x-3 and y=-x+3 intersect?
how did world events make it possible for President Jefferson to double the size of the United States? PS: it has to be 30 words or more
what did karl marx do for the russian revolution?
An experiment consists of rolling two fair number cubes. What is the probability that the sum of the two numbers will be 8? Express your answer as a fraction in
What method did party bosses use to maintain the power of their political machines?
an annuity has an initial balance of $5000. annual withdrawals are made in the amount of $800 for 9 years, at which point the account balance is zero. what annu
What was the outcome of the Battle of Quebec?