Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

• Write the following Java methods: 1. boolean real-sols(double a, double b, dou

ID: 3688241 • Letter: #

Question

• Write the following Java methods: 1. boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions 2. double solution1(double a, double b, double c): If the equation ax2 + bx + c has real solutions it return the smallest of the two. If it doesn’t have real solutions it should return the value 0 and an error message. 3. double solution2(double a, double b, double c): If the equation ax2 + bx + c has real solutions it return the biggest of the two. If it doesn’t have real solutions it should return the value 0 and an error message. (if the change *b2-4ax = change* is less than 0; there is no solution)

Test your methods within a class and check that they work properly. Use the method real-sols(double a, double b, double c) in the implementation of the other 2 methods.

Explanation / Answer

class CalculateSolution{

double a ,b, c;

public :

boolean real-sols(double a, double b, double c){

double D = b^2-4*a*c;

if(D>=0) return true; else return false;

}

double solution1(double a, double b, double c){

boolean real = real-sols(a, b, c);

if(real==true){

double D = b^2-4*a*c;

double x1 = -b+sqrt(D)/(2*a); double x2 = -b-sqrt(D)/(2*a);

if( D> =0){

if(x1>x2) return x2; else return x1; }

}

else if (real==false) {

}

else

}