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

Respuesta :

ijeggs

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");

       }

   }

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