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

  Integrated services architecture

Explain how has the integrated services architecture is being provided a solution to growing variety and volume of traffic experienced within the Internet and Intranets? Describe in scholarly detail.

  What is green computing and green communication technology

What is Green Computing and Green Communication technology.

  Cashregister requires to support a method void undo()

imagine the CashRegister needs to support a method void undo() that undoes the addition of the preceding item. This enables a cashier to quickly undo a mistake. What instance variables should you add to the CashRegister class to support this modif..

  Explain what you will do to minimize the errors

make an array with 5 elements of type int in a for loop go from 0 to 5 (which means 6 elements) and try to print all elements; the program will compile, but what happens when you run it? What error message do you get.

  Systems analyst at a manufacturing company in seattle

You are the Systems Analyst at a manufacturing company in Seattle, WA. A Systems Analyst in your company's New York office sends you a trace file to analyze. The complaint is that an end-users machine cannot connect to any of the network devices o..

  Suppose cookies are not disabled on the client

suppose cookies are not disabled on the client.

  Write down a program that prompts the user to input

Write the program that prompts the user to input the x-y coordinate of a point in a Cartesian plane. The program should then output a message indicating whether the point is the orgin, is located on the x (or y) axis, or appears in a particular qu..

  Implement needham-schroeder protocol using python

Implement Needham-Schroeder symmetric key protocol, both original version and fixed version using python.

  Discuss information technology profession and ethics

Discuss the Information Technology profession and professional ethics in this profession.How would professional ethics be implemented in an organization.

  Assume a direct access file consists of sectors

assume a direct access file consists of sectors with 1024 byte capacity. Suppose also that records are 32 bytes long. On which logical sector do the following logical records lie? What is the relative record number in the sector?

  How to write a sql insert statement

Write down a SQL query that joins two tables in the example database and uses BETWEEN to restrict record selection (use salaries to restrict the data).

  Explain the characteristics of a high performance team

Listing and define six major SDLC phases and the products of each. Indicate the CASE tools that would be used to support each phase.

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