Write a Java expression for the following: √b^2-4ac
Answers
Answered by
7
Write a Java expression for the following: √b^2-4ac
Answer: Math.sqrt((Math.pow(b,2))-(4*a*c))
Answered by
5
Answer:
Java expression for √(b² - 4ac) is -
- Math.sqrt(b*b - 4*a*c) or,
- Math.sqrt(Math.pow(b,2) - 4*a*c)
Explanation:
- To calculate square root of positive number, the Math.sqrt() function is used. Here, sqrt() function is used to find the square root of b² - 4ac.
- Math.pow(x, y) returns x raised to the power y. To calculate b², we wrote Math.pow(b, 2). We can also write b*b there but for larger values like b^20, b^30, it is time consuming to multiply b 30 times. So, for that case, Math.pow() function is used.
Similar questions