# Thread: program for a quadratic formula

1. Member Join Date
Jan 2009
Posts
4
Rep Power
0

## program for a quadratic formula

im suppose to write a program to compute the solutions for a quadratic formula, where a=4, b=30, and c=10. the perameters must be declared as ints
how do i do that? there's a specific code for if i want to square something, i think its Math....something something... but i dont remember. plz help! 2. ## Math ...

Here's the link to the Math class and it's methods:
Math (Java Platform SE 6)

Luck,
CJSL

PS: I think you're looking for the sqrt() method 3. ## What you need is the Java API. It will have all the info you need. Here's the API for the Math class:
Math (Java Platform SE 6)
And the "Master" API:
Overview (Java Platform SE 6)

Luck 4. ## it much faster to use int sideA = a*a; then to use the Math class. 5. ##  Originally Posted by angryboy it much faster to use int sideA = a*a; then to use the Math class.
I'm a bit confused how you would avoid using the Math class for a general solution to the quadratic equation? I suppose you could use Newton's approximation of square roots, but that seems a bit overkill. 6. ## there's a specific code for if i want to square something, i think its Math....something something...
i didn't mean to avoid the Math class all together. I was just suggesting that its faster to square the numbers using a*a. rather than using Math.pow().

you could actually cal for sqrt, but its a crazy math formular. better to use Math.sqrt() for that part... 7. ##  Originally Posted by angryboy i didn't mean to avoid the Math class all together. I was just suggesting that its faster to square the numbers using a*a. rather than using Math.pow().
I agree 100%. I didn't see where someone had suggested using Math.pow(), just sqrt, and probably that confused me. 8. ## huh?

Angryboy... you on something? Let's see... I give a link to the Math class and tell the OP that the sqrt() is probably what is needed. How did you come to the conclusion that I was suggessting that the OP develop the sqrt() method? I think it would be obvious that I'm refering to the sqrt() method in the link to the Math class.
As for the a*a vs Math.pow(), yeah... that's sounds pretty logical...

CJSL 9. ##  Originally Posted by CJSLMAN Angryboy... you on something?
lol nah, you misunderstood what i wrote. maybe you on something...
like i said to fubarable, use a*a and Math.sqrt(). 10. ## ok...

Oh... OK... sorry if I misunderstood your post... and I agree with both you and Fubarable .... a*a and Math.sqrt().

Thanks,
CJSL #### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•