61.4k views
5 votes
Given that a function receives three parameters a, b, c, of type double , write some code, to be included as part of the function, that determines whether the value of "b squared" - 4ac is negative. If negative, the code prints out the message "no real solutions" and returns from the function

User Cmyker
by
4.3k points

1 Answer

1 vote

Answer:

public static void quad(double a, double b, double c) {

double D = (Math.pow(b, 2)) - (4 * a * c);

if (D<0){

System.out.println("no real solutions");

}

}

Step-by-step explanation:

The code snippet above implements the function in Java programming language

As required by the question, the line double D = (Math.pow(b, 2)) - (4 * a * c); evaluates b squared" - 4ac and assignes the value to the variable D

An if statement is used to test if D is less than 0, if this is true the message no real solutions is printed

User Larae
by
3.9k points