BreeA - 1 year ago 39

Vb.net Question

`Function quadratic (a As double, b As double, c As double) As Double`

Dim x,y As Double

if (a = 0) then

Console.Writeline("no solution for a = 0")

else if

((b * b - 4 * a * c) <0)

Console.Writeline("no real solutions")

else

x = ((- b + Math.Sqrt(b * b - 4 * a * c)) / ( 2 * a))

y = ((- b - Math.Sqrt(b * b - 4 * a * c)) / ( 2 * a))

if (x > y) then

Console.Writeline(x)

else

Console.Writeline(y)

End if

End if

End Function

Answer Source

I am not going to check your math for you :-) but if you change this:

```
else if
((b * b - 4 * a * c) <0)
Console.Writeline("no real solutions")
```

To this:

```
ElseIf ((b * b - 4 * a * c) < 0) Then
Console.Writeline("no real solutions")
```

It compiles and runs...