Write a program that prompts the user to enter:
The program should then display a plot similar to the one shown below:
The user should enter these values with through JOptionPane dialogs.
They should look something like this:
The plot consists of a number of connected line segments that approximate a curve; the number of line segments (or “steps”) is specified by the first user-entered value. The first line segment begins at
x = drawWidth * sin(0), y = drawHeight * cos(0)
where drawWidth is 40% of the width of the window and drawHeight is 40% of the height of the window.
The first line segment ends at
x = drawWidth * sin(sineCycles * stepSize), y = drawHeight * cosine(cosineCycles * stepSize)
where drawWidth and drawHeight are 40% of the window width and height, sineCycles is the second value entered by the user, and cosineCycles is the third value entered by the user.
Also, stepSize = 2 * PI / steps where steps is the first value entered by the user.
The second line segment goes from the end of the first line segment to
x = drawWidth * sin(2 * sineCycles * stepSize), y = drawHeight * cosine(2 * cosineCycles * stepSize)
The third line segment goes from the end of the second line segment to
x = drawWidth * sin(3 * sineCycles * stepSize), y = drawHeight * cosine(3 * cosineCycles * stepSize)
…
Since the number of cycles is an integer value, the last line segment goes from the end of the second to last line segment back to the beginning of the first line segment. In the example shown above, this results in ten line segments that trace a circle.
WinPlotter class used in previous lab assignments.Color class in the java.awt package for this.setPlotBoundaries from the WinPlotter class.Once you've completed the assignment requirements, you may wish to add some additional features. Some things you may consider:
Can you produce the following?
Record the time you spent on this assignment in FAST, and demonstrate/submit your assignment as specified by your instructor.