Forums Register Login

Using the Math Class + generic question

+Pie Number of slices to send: Send
Hey all, I'll just get straight to it, when I input a vertical height of 4 and a top angle of 30 (in degrees) I get ridiculous answers,
for example, the ladder length should be 5, and the floor length should be 3 (a 3, 4, 5 triangle) but I get huge decimal answers and can't figure out why.

Here is the code of the class containing the main method and scanner


And this is the code of the calculations etc



My other, generic, question is about the constructor and the print statements at the end of the User class. Do I have to assign values to things such as bottomAngle, floorLength etc in the constructor, and then use +bottomAngle in the println statements?
Or is there a way I can use getBottomAngle() and call the "local variable" (is that the right term)??

Thanks for all your help so far guys.
The reason I'm not sure what the problem is, is because it is clearly not giving me the answer as if I had done cosine, sine, or tangent of the input angle in radians, I have checked on my calculator and I've no idea where these values are coming from!!
+Pie Number of slices to send: Send
Everything there looks okay to me except for your assertion that a 3-4-5 right triangle has a 30-degree angle, and that shouldn't make a huge difference. (I haven't seriously checked your trig calculations either but they look like they're going in the right direction anyway.)

So can you post more detail about the answers you're getting? I'm sure you aren't going to get 5 for ladder length, but you should get something around there.
+Pie Number of slices to send: Send
This is why I shouldn't do these things at such ridiculous times.
You're correct, and I'm taking a maths degree thinking a 3 4 5 triangle has a 30 degree angle :|

I'm just going to say ohhh it happens to the best of us and quietly brush this one away ;)
Thanks though
+Pie Number of slices to send: Send
Agree. If you are taking maths you should never think there is a 30° angle. You should have said π÷6
Create symphonies in seed and soil. For this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 923 times.
Similar Threads
Calling methods from another class with constructors
Null pointer exception thrown in paintComponent
Identifier expected
Problem with aggregation of multiple classes
Generic methods/classes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 06:39:55.