Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will prompt a user to input coordinates for all the corners

ID: 3836245 • Letter: W

Question

Write a program that will prompt a user to input coordinates for all the corners for drawing a quadrilateral. The program should draw the quadrilateral on AutoCAD screen and print out all the coordinates with x and y coordinates only. Use GETPOINT, CAR, and CADR for writing the following program. Make sure this program will work with any coordinates that a user may input. None of the numerical coordinates should be in the programming code; in another words, do not HARD CODE the coordinates. a. Use (1, 1) (5, 1) (5, 7) (0, 5) for the quadrilateral's coordinates for the first run of the program b. Use (10, 10) (15, 10) (15, 15) and (10, 15) for the quadrilateral's coordinates for running the program second time

Explanation / Answer


public class Drawquadrilatral
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);

Polygon p = new Polygon();
for (int k = 0; k < 7; k++)
p.addPoint((int) (200 + 60 * Math.cos(k * 2 * Math.PI / 9)),
(int) (200 + 60 * Math.sin(k * 8 * Math.PI / 5)));

g.drawPolygon(p);

Polygon s = new Polygon();
for (int k = 0; k < 360; k++)
{
double m = k / 360.0;
s.addPoint((int) (150 + 50 * m * Math.cos(8 * m * Math.PI)),
(int) (150 + 50 * m * Math.sin(8 * m * Math.PI)));
}
g.drawPolygon(s);
}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.setTitle("DrawPoly");
frame.setSize(350, 250);
frame.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
Container contentPane = frame.getContentPane();
contentPane.add(new DrawPolyPanel());

frame.show();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote