Tuesday, July 28, 2009

Please help w/ making a program, it just doesn't make any sence?

ok in school we're using Visual Basic 2005 to make an application program. We're basically finding how far away from the horizon this person is standing. The user has to be able to type in the number of feet high they are (standing on a platform). we're assuming that the earth is exactly round and the radius is 4000 miles. So it's a pathogorean theorem thing (a^2 + b^2 = c^2) where c=4000 miles + (whatever the user types in) * 5280, because it has to be converted to miles. b=4000, that's the constant. and we're trying to find a. This is what i've come up w/, but it didn't work:





Const sngB As Single = 4000


Dim sngC1 As Single


sngC1 = Val(txtprompt.Text)


Dim sngC As Single


sngC = sngC1 + 4000


Dim sngA As Single


sngA = (sngC^2) - (sngB^2)


Dim sngResult As Single


sngResult = Math.sqrt(sngA)


lblResult.Text = sngResult





if that doesn't make sence but you know how to do this, please email me, i really need help with this

Please help w/ making a program, it just doesn't make any sence?
Your equation is right.





A = sqrt( (c^2) - (b^2) )





Plugging in easy numbers (for instance, 1 mile above the ground), you get:





A = sqrt( (4001^2) - (4000^2) )





Which comes out to 89.448.





If when you run the program you get something close to that, good. Everything is fine.





If you're not, perhaps you're entering the height of the platform in feet, but forgetting to change it to miles before it gets added to C. In that case, you'd want to do something like:





sngC1 = Val(txtprompt.Text)


sngC1 = sngC1 / 5280


sngC = sngC1 + 4000





As for the other answers, Jamall has no idea what he's talking about. Ignore him.


Mom23 forgot the radius of the earth in his or her answer. What he or she should have written is


c = sqrt(4000^2 + ((a / 5280)+4000)^2)





If you continue to have issues, feel free to e-mail me. I'll try to help as much as I can.
Reply:c is the hypotenuse so the diagonal value is c which what you should be looking for


b is either the opposite side or the adjacent side but since you defined it as the earths radius it is the adjacent side or the height of the earth's radius


%26lt; he is here


\


| \


a \ c = is the distance between you and him


|__\ %26lt; you are here


b = distance between you and earth center


a = distance between him and earth he is standing on a


flatform so = earth's radius + vertical distance





so you really should compute for c





c^2 = a^2 + b^2


sqrt(c) = sqrt(a^2 + b^2)





so your code should be


a= b + (val(txtprompt.text) / 5280) ' converting it feet to miles


c = sqrt( (a * a) + (b *b))





i'm not really sure but it think this is the answer :)





sorry I can't get the diagram right.
Reply:I think your math is wrong.





C does not = 4000 + a*5280





c = sqrt(4000^2 + (a*5280)^2)





try that





**************





update: thanks to the guy below - sorry for trying to solve to quickly at night after wrangling 3 kids! (Ya lose it if ya don't use it!) LOL!
Reply:Well it most DEFINATELY doesn't make sense because B=C is logically impossible. If c=4,000 Miles, then why would you multiply that again, because C is your answer. If you're going to do anything with C, it's divide. I don't know the answer, but that's some math help that's probably REALLY good to know...

survey monkey

No comments:

Post a Comment