• Post Reply Bookmark Topic Watch Topic
  • New Topic

solve quadratic equations with arrays  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am suppose to write a method for solving a quadratic equation using the following header:

public static int solveQuadratic(double[] eqn, double[] roots)

I have entered 1, -3 and -4. The answer I get is "The solution is:0.0" .
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply put, roots[0] is always zero because you never assign it a value. I'm sure you meant to, at line 51 of your code for example, but you didn't.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!