The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

This program takes user input and makes some calculations such as area perimeter and angles. Assume the user enter x1=0, x2=0, y1=3, y2=0, z1=3, and z2=4. If a user inputes these numbers when they are callled to do so, all the proper calculations will be made except for angles. I have been stuck on the angle part for an hour and a half trying all different variations of the law of cosines in my code, which is, cos C = (a² + b² - c²)/2ab. I cant get it to work at all though. If anyone could just write it out in code for me for just one of the angels, that would be great, as i could modify it accordingly to find the other ones by myself. Like i said ive been at this for hours and i cant get it to work so its becoming really frustrating. Please help if you can. Thanks!

Re: Law of cosines help to find angles URGENT!

What are you trying/have tried? Is there anything in the Math class that could help?

Another thing, you should really set all the values for your instance variables in your constructor. There is nothing stopping you from calling methods in the constructor. You're currently only setting coordinates. That's how I would do it, I'm pretty sure that's the preferred way to create an object.

Re: Law of cosines help to find angles URGENT!

Yeah i realize its messy and know how i can fix it with my next program but i am right near the end of this one so .im not gonna both going back to change anything now. As of right now i have gotten the computation of angleB to come out correctly for me here :

So all i need now is angleA and i can get angleC with no problem. I have tried revising the code from getAngleB to make it work with a but i have tried all the variations(i think) and cant get it to work. The correct angle for angleA would be 53.13010235415598, but i cant get that number to come out no matter what i try. Do you have anything that you think might work?

--- Update ---

And im not trying to be pushy or anything, but if you are still trying to help me, this assignment is due in 40 minutes, so if you could help within that time frame that would be awesome.