Write a program that passes the coordinates of five points

Assignment Help Computer Engineering
Reference no: EM13322695

Write a program that passes the coordinates of five points from the command line as follows java Exercise13_31 x1 y1 x2 y2 x3 y3 x4 y4 x5 y5. The first four points for a polygon, and the program displays the polygon in a panel and a message in a alabel that indicates wheter the fifth point is inside the polygon.

Here is what i have so far...

import javax.swing.*;

import java.awt.*;

public class Lab13_31Montgomery extends JFrame {

private JLabel jlblMessage = new JLabel("", JLabel.CENTER);

public Lab13_31Montgomery() {

setTitle("Draw Polygon");

add(new PolygonPanel());

add(jlblMessage, BorderLayout.SOUTH);

if (polygon.contains(p1))

jlblMessage.setText("The point is inside the polygon");

else

jlblMessage.setText("The point is outside the polygon");

}

 

}

 

public static void main(String[] args) {

//prompt user to enter points

System.out.println("Enter 5 points, first four are points of Polygon, the last is to be tested");

 

// Pass command-line arguments

if (args.length != 10) {

System.out.println(

"Usage: java Exercise14_32 x1 y1 x2 y2 x3 y3 x4 y4 x5 y5");

System.exit(1);

}

Lab13_31Montgomery frame = new Lab13_31Montgomery();

frame.setSize(400, 400);

frame.setLocationRelativeTo(null);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

Polygon polygon = new Polygon();

polygon.addPoint(Integer.parseInt(args[0]), Integer.parseInt(args[1]));

polygon.addPoint(Integer.parseInt(args[2]), Integer.parseInt(args[3]));

polygon.addPoint(Integer.parseInt(args[4]), Integer.parseInt(args[5]));

polygon.addPoint(Integer.parseInt(args[6]), Integer.parseInt(args[7]));

}

}

class PolygonPanel extends JPanel {

@Override

protected void paintComponent(Graphics g) {

super.paintComponent(g);

g.drawPolygon(polygon);

}

}

Reference no: EM13322695

Questions Cloud

Write a function that accepts as arguments the following : The function should determine the median of the array. This value should be returned as double. (Assume the values in the array are already sorted).
What is the speed of the masses after the collision : A 2.0-kg mass moves with a speed of 5.0 m/s. It collides head-on with a 3.0 kg mass at rest. If the collision is perfectly inelastic, what is the speed of the masses after the collision
Write a program which reads a file and creates a file : Create your own file to test your program. Your job is to set up the input and output files to have the program read from a file and write to a file.
Compute the number of moles of gas present : A sample of nitrogen gas kept in a container of volume 2.9 L and at a temperature of 39°C exerts a pressure of 4.7 atm. Calculate the number of moles of gas present
Write a program that passes the coordinates of five points : Write a program that passes the coordinates of five points from the command line as follows java Exercise13_31 x1 y1 x2 y2 x3 y3 x4 y4 x5 y5.
What is the separation between the first-order minima : Monochromatic light (lambda = 670 nm) is incident on a single slit and forms a diffraction patter on a screen 95 cm away. what is the separation between the first-order minima
Explain what is the pressure of the gas in mmhg : The volume of a gas is 2.80 L, measured at 1.00 atm. What is the pressure of the gas in mmHg if the volume is changed to 9.11 L
Propose a ip network scheme to accommodate the needs : Propose a IP network scheme to accommodate the needs of the office above. Your proposal should incorporate the most efficient use of network/host using VLSM and a second option using FLSM. Provide pluses and minuses for each option.
How far will the image of the object lie from the right end : A plastic cylinder of length 38 cm its ends ground to convex (from the rod outward) spherical surfaces, each having radius of curvature 19 cm, How far will the image of the object lie from the right end

Reviews

Write a Review

Computer Engineering Questions & Answers

  Determining the companys checkbook or ledger

The subcontractor says that original check was for only $10,750. Jonathan looks around office however was not able to determine the company checkbook or ledger.

  Registers and memory address

Suppose that the .data section is mapped to the start at address 0x1800 in memory at run time, Provide the contents of the registers %r1-%r4.

  Identify the three basic kinds of e-commerce

Identify the three basic sorts of e-Commerce. How do their strategic roles differ? What are the benefits and disadvantages to organizations, sellers, and consumers.

  Build a read-write property named validlastname

Create a read-write property named ValidLastName that stores a String value in the hidden variable mstrLastName. design the property using a Property Procedure.

  Write down the names of five currencies

Write down a C program that displays a title, "Currency Conversion," and then write the names of five currencies and their equivalents to the US dollar. The conversions are hard coded equations.

  Give most popular ways today to code a database application

Embedded SQL applications tend to lack interoperatiliby. Applications might have to modified to work with other RDBMS ODBC applications do not need the explicit declaration and use of host variables.

  Assume f is a function

assume f is a function that returns the result of reversing the string of symbols given as its input, and g is a function that returns the concatenation of the two strings given as its input. If x is the string abcd, what is returned by g(f(x),x).

  Distinguish between open and closed applications.

explain  HTML, XML and Java programming. What is the difference between the three.

  Define the context in which normalization is used

define the context in which Normalization is used. What is its purpose.

  Why array names are not assignable variables in c

Why  array names are not assignable variables in c

  Designing an e-r diagram

Assume that at PVF, every product (explained by Product No., Description, and Cost) is composed of at least three elements (explained by Component No., Description, and Unit of Measure). Design an E-R diagram for this situation.

  Define the way in which a person writes or sends e-mails

explain a scenario in which someone displayed bad netiquette. How did someone react to receiving the email? what could the sender have done differently to display good netiquette.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd