#Did I solve the task correctly?

1 messages · Page 1 of 1 (latest)

grand cloud
#

My code:
void main() {
double a = 2.0;
double b = 8.0;
double c = 3.0;

double x1 = (-b + Math.sqrt(b * b - 4.0 * a * c)) / (2.0 * a);
double x2 = (-b - Math.sqrt(b * b - 4.0 * a * c)) / (2.0 * a);

IO.println(x1);
IO.println(x2);

}

wary iglooBOT
#

<@&987246399047479336> please have a look, thanks.

arctic glade
#

Looks good. Small nitpick on the question, a,b,c are called "coefficients" not "prefixes".

stray dirge
#

^ @midnight rivet

hexed jackal
#

just little tips
you could create variable that hold the value of Math.sqrt(b * b - 4.0 * a * c)
so you do not calculate it twice
part of a clean code that you do not repeat yourself
and well done

grand cloud
#

Thanks all

hexed jackal
#

you welcome

midnight rivet
#

On the list to fix