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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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