Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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);

}

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9901997

Have any Question?


Related Questions in Computer Engineering

A chemistry student needsnbsp700 ml of dimethyl sulfoxide

A chemistry student needs 70.0 mL of dimethyl sulfoxide for an experiment. By consulting the  CRC Handbook of Chemistry and Physics , the student discovers that the density of dimethyl sulfoxide is 1.10 g.cm^-3. Calculat ...

Question suppose that a table has 9 columns it is known

Question : Suppose that a table has 9 columns. It is known that we only need to provide values for 4 columns explicitly to insert a new row successfully. Assume that there are n columns with default values and there are ...

Setting youre a junior accountant for a steel manufacturing

Setting: You're a junior accountant for a steel manufacturing firm in West Virginia, with $3 billion in revenues in 2016. You're sitting in a budget meeting as the assistant to the CFO. The meeting is with the executive ...

Question 1 should on four different conflicts you have

Question: 1. Should on four different conflicts you have encountered. These conflicts can be work related or personal conflicts. The presentation will consist of 5 slides from each group member and must have at least 1 a ...

Command to mail only the process id of running java program

Command to mail only the process ID of running Java program test to the email address (single line Unix)

Please discuss the followingas demand increased for these

Please discuss the following: As demand increased for these mortgage backed securities, lenders reacted by relaxing their approval standards to increase production. No longer were "all" borrowers required to document the ...

Question suppose you want to achieve a speedup of 90 times

Question : Suppose you want to achieve a speedup of 90 times faster with 100 processors. What percentage of the original computation can be sequential? Assume one byte data value is 1101, 1000(binary). When we decode the ...

Determine the percentage of mass of the atmosphere that

Determine the percentage of mass of the atmosphere that resides between sea level and a height of 18.3 km. Assume an average pressure of 1.00 atm at sea level and a temperature of the atmosphere of 15 °C. The average mol ...

Question review ram flash memory magnetic and optical

Question : Review RAM, Flash Memory, Magnetic and Optical storage technologies concerning their placement in the usage hierarchy of contemporary computer systems. Include size, speed and cost considerations at each level ...

Case study 1 user interfacesearly user interfaces were

Case Study 1: User Interfaces Early user interfaces were designed with little or no consideration for the end user. This was largely due to technical and hardware limitations. The poor interface design required a specifi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As