![]() |
I have to do program which calculates x and y couples using next formulas:
x=(40*cos)+60*Math.cos((2/3)*t); y=(40*sin)-60*Math.sin((2/3)*t); the output of the program should look something like this: x | y 1234 | 3456 // x and y results 2234 | 8923 1256 | 9842 "t" should change after 0,01 step (from -10 to 10) (So in output there should be 2000 couples of x and y + first line x|y) I tried to program but got only more confused after hours of trying...biggest problem is that "step" thing...and that "t" should change after every step... I hope there's anyone that could help me ... |
Sounds easy enough... Since this is a homework assignment, I'd like to see effort (code) on your end before I contribute code.
The "step" problem, would be a loop with an index variable that increments through from -10 to 10. |
/*at the end my code was like that, but x and y were not right (maybe i did something wrong with x and y calculating
http://www.itcollege.ee/~kkoemets/kodused2...l_51b41c47.gif- x and y should be like that*/ :
//starting my code: |
looks like you got it right to me ... what you wrote calculates x & y correctly (going by the formula you have provided)
|
Looks good. The code achieves your 2000+1 lines of output.
Drunken coder has confirmed the value is correct... you can plug them into a calculator to confirm further if needed. :
public class Hindeline1 |
| All times are GMT -5. The time now is 12:42 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC