Square Root

F

f2prateek

I need to calculate the roots of a quadratic equation by formula.But
how do I use the math.sqrt thing?
 
J

Jeff

f2prateek said:
I need to calculate the roots of a quadratic equation by formula.But
how do I use the math.sqrt thing?

Do a google search on java math.sqrt The first link will give you the
class definition which you can use. Basically, this should be in the
comp.lang.java.help newsgroup as it is pretty much rank beginner stuff,
and that group is more for people just getting started with java.

However, giving you the fish as well as teaching you to fish, code
like:

double a, b, c, root1, root2;
a = 1;
b = 4;
c = 7; //picked random numbers
root1 = ((-1 * b) + (Math.sqrt((b * b) - (4 * a * c))) / (2 * a);
root2 = ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top