import java.io.*;
import java.util.*;
import java.lang.*;
public class PointApp{
public static void main(String[] args) throws Exception
{
Scanner scanner = new Scanner(new File("test.txt"));
int [] tall = new int [100];
int i = 0;
while(scanner.hasNextInt())
{
int x1= scanner.nextInt();
int y1= scanner.nextInt();
int x2= scanner.nextInt();
int y2= scanner.nextInt();
//System.out.println(x1+" "+y1+" "+x2+" "+y2);
int k = cord(x1,y1);
int l = cord(x2,y2);
int sum = cord(x1+x2,y1+y2);
System.out.println("P1("+x1+","+y1+")(quadrant "+k+")"+"P2("+x2+","+y2+")(quadrant "+l+")");
System.out.println("P1+P2:("+(x1+x2)+","+(y1+y2)+")(quadrant "+sum+")");
if(x1==x2)
System.out.println("P1 and P2 are reflections across the x-axis");
if(y1==y2)
System.out.println("P1 and P2 are reflections across the y-axis");
if(x1==(-1*x2) && y1==(-1*y2))
System.out.println("P1 and P2 are reflections through the origin");
if(x1!=x2 && y1!=y2)
if(Math.abs(x1-0)==Math.abs(x2-0) && Math.abs(x1-0)==Math.abs(x2-0))
System.out.println("P1 and P2 are equidistant from the origin");
double d = dist(x1,y1,x2,y2);
System.out.println("distance between P1 and P2 is "+d + "\n");
}
}
public static int cord(int x, int y){
int k=0;
if(x>=0){
if(y>=0)
return 1;
else
return 4;
}
if(x<0){
if(y>=0)
return 2;
else
return 3;
}
return -1;}
public static double dist(int x1, int y1, int x2, int y2){
double i = Math.pow(x2-x1,2);
double j = Math.pow(y2-y1,2);
double v = Math.sqrt((i+j));
return v;
}
}
JAVA - Please follow ALL instructions, thank you!! Here is the API, for a Point class...
INSTRUCTIONS: I NEED TO CREATE A PointApp PROGRAM THAT USES THE FOLLOWING API DOCUMENTATION. Below the API Documentation is the code I submitted. However, the output is different for what they are asking. I am looking for someone to fix the code to print out the correct output and to add comments so I can have an idea in how the code works. PLEASE AND THANK YOU. API DOCUMENTATION: public class Point extends java.lang.Object The Point class is used to...
Java Help 2. Task: Create a client for the Point class. Be very thorough with your testing (including invalid input) and have output similar to the sample output below: ---After declaration, constructors invoked--- Using toString(): First point is (0, 0) Second point is (7, 13) Third point is (7, 15) Second point (7, 13) lines up vertically with third point (7, 15) Second point (7, 13) doesn't line up horizontally with third point (7, 15) Enter the x-coordinate for first...
Create a MyPoint class to model a point in a two-dimensional space. The MyPoint class contains: • Two data fields x and y that represent the coordinates. • A no-arg constructor that creates a point (0,0). • A constructor that constructs a point with specified coordinates. • Two get functions for data fields x and y, respectively. • Two set functions for data fields x and y, respectively. • A function named distance that returns the distance from this point...
Please follow all the instructions and do all the parts (a-d)! Create a Java program which implements Dijkstra’s shortest path algorithm according to the psueudocode below. Base the design on the weighted graph implementation used in Problem3.java (provided at the bottom). Your program should include the following features: a. A new method receives a starting vertex index and a target vertex index (e.g. 0 and 4). It computes the shortest distances to all vertexes using Dijkstra’s algorithm. The pseudocode is...
1. You often need to know the inheritance ____________________ of the Java API to work with its classes and subclasses. 2. All objects have access to the methods of the ____________ class. 3. If two classes share some common elements, you can define those elements in a ____________. 4. To call a constructor or method of a superclass from a subclass, you use the ____________ keyword. 5. A class that can be inherited by another...
JAVA I. Using the Event Class created previously, create an array of objects; II. Demonstrate passing array reference to a method; III. Demonstrate creating array of objects that prints out only x 0.0 for all objects. PROJECT 5C - ARRAYS Create a new file called " EventArray5C". There are some "challenging" directions in this project. . 1.Prepare a document box (tell me that task(s) the application is to accomplish, how it will accomplish the tasks, the author of...
Draw the UML DIAGRAM ALSO PLEASE DRAW THE UML DIAGRAM.ALSO in java should use the program in java For this task you will create a Point3D class to represent a point that has coordinates in three dimensions labeled x, y and z. You will then use the class to perform some calculations on an array of these points. You need to draw a UML diagram for the class (Point3D) and then implement the class The Point3D class will have the...
Please help with program this. Thank you so much in advance! Create a Java program which implements a simple stack machine. The machine has 6 instructions Push operand Puts a value on the stack. The operand is either a floating point literal or one of 10 memory locations designated MO M9 Pop operand Pops the value on the top of the stack and moves it to the memory location MO-M9 Add Pops the top two values off the stack, performs...
NEEDS TO BE IN PYTHON: (The Point class) Design a class named Point to represent a point with x- and y-coordinates. The class contains: - Two private data fields x and y that represent the coordinates with get methods. - A constructor that constructs a point with specified coordinates, with default point (0, 0). - A method named distance that returns the distance from this point to another point of the Point type. - A method named isNearBy(p1) that returns...
Write a class called Point that contains two doubles that represent its x- and y-coordinates. It should have get and set methods for both fields. It should have a constructor that takes two double parameters and initializes its coordinates with those values. It should have a default constructor that initializes both coordinates to zero. It should also contain a method called distanceTo that takes as a parameter another Point and returns the distance from the Point that was passed as...