Write a graphical application that has the following characteristics: • Its panel is 350 pixels wide by 200 pixels high. • It draws a horizontal line through the panel’s center point. • It randomly...


Write a graphical application that has the following characteristics:


• Its panel is 350 pixels wide by 200 pixels high.


• It draws a horizontal line through the panel’s center point.


• It randomly paints either a circle or a square at a random location.


• The color of the circle or square depends on its location relative to the horizontal line, as follows: It is blue if its center is above the line, green if its center is below the line, and red if its center is on the line.


Generate two random integers that are the x- and y-coordinates of the center of the circle or square. Be sure that these coordinates lie within the window. Then generate another random integer. If it is even, paint a circle; other-wise paint a square. Let the diameter of the circle or the length of the side of the square be 20 pixels.



May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here