Thumbs 09-08-2003, 08:46 PM Hi, I got sent a challenge, and I'm stuck. the equation is
where A =2 B = 10 and C = 2
What I have so far is
dblA = Val(txtValueA.Text)
dblB = Val(txtValueB.Text)
dblC = Val(txtValueB.Text)
dblDisc = dblB ^ 2 - 4 * dblA * dblC
If dblDisc < 0 Then
lblAnswer.Caption = "there are no roots!"
ElseIf dblDisc = 0 Then lblAnswer.Caption = -dblB / 2 * dblA
Else: lblAnswer = -dblB + Sqr(dblDisc / 2 * dblA * dblC) & -dblB - Sqr(dblDisc / 2 * dblA * dblC)
End If
End sub.
if anyone could help me, I owe you one for sure!
thanks alot!
if want, you can email me at makeshift.designs@cogeco.ca
-Chris
Thumbs 09-08-2003, 08:47 PM this is the equation
http://home.cogeco.ca/~adames/22.bmp
rajeeshun 09-08-2003, 10:02 PM this is the equation
http://home.cogeco.ca/~adames/22.bmp
...Hello
What is your question ??? Are you getting any error ?What output you are expecting from your calcultation ???
DirectAllX 09-08-2003, 10:09 PM that's wrong, the equation is divided just by 2A, not by 2AC
Latac 09-08-2003, 10:37 PM well, * = times, ^ = powers, / = divide, - = minus, + = add, and they have greater than signs >
not hard to figure out.
edit: Think I misunderstood you.. you want that problem into VB format? lol
rajeeshun 09-08-2003, 10:51 PM well, * = times, ^ = powers, / = divide, - = minus, + = add, and they have greater than signs >
not hard to figure out.
edit: Think I misunderstood you.. you want that problem into VB format? lol
...
Ya.. I've done greate mistake... I wud not have to asked more specific details for your question to give the correct answer... Sorry !!!
Kinguy 09-09-2003, 12:04 AM I believe division comes before multiplication in the order of operations. So you need more parantheses.
Try something like:
If (b ^ 2 - 4 * a * c) < 0 Then
MsgBox "No real roots"
ElseIf (b ^ 2 - 4 * a * c) = 0 Then
MsgBox "Roots are " & b / (2 * a)
ElseIf (b ^ 2 - 4 * a * c) > 0 Then
MsgBox "Roots are " & ((-b) + Sqr(b ^ 2 - 4 * a * c)) / (2 * a) & " and " & ((-b) - Sqr(b ^ 2 - 4 * a * c)) / (2 * a)
End If
Thumbs 09-09-2003, 05:19 AM Thanks alot guys, sorry I forgot to mention, the roots have to be
"1.9 - 2.9"
I can get 2.9, but have yet to get 1.9.
hmmmm....
Thumbs 09-09-2003, 05:33 AM oh and, I tried that equaton, it didn't give me the answer that I was looking for, but it was very neat, and very close. thanks
Iceplug 09-09-2003, 06:59 AM Are the roots supposed to be 1.9 and 2.9
for a=2, b=10, and c=2?
I don't think so, since Sqr(b^2-4ac) / 2a would have to be 0.5 for this case... and it seems to be Sqr(100-16)/4 = Sqr(21), which isn't 0.5 :).
Thumbs 09-09-2003, 07:34 PM yea, I am saying what is wrong with my equation, those roots are what I am supposed to get.
Iceplug 09-10-2003, 06:44 AM Nothing is wrong with the equation... the roots are incorrect for those specified values of a, b, and c.
For 1.9 and 2.9, you'd need these values of b and c.
(x - 1.9)(x - 2.9) = x2 - 4.8x + 5.51
with b <= b/a and c <= c/a :). Your b would be 10/2=5 and c would be 2/2 = 1
|