Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

package ppoint; import java.util.*; class Point{ //instance variables private do

ID: 3762847 • Letter: P

Question

package ppoint;
import java.util.*;
class Point{
//instance variables
private double x;
private double y;
  
//no argument constructor
public Point(){
x=0;
y=0;
}
//constructor that takes two arguments
public Point (double a, double b){
x=a;
y=b;
}
//accessors (getters)
public double getx()
{return x;}
public double gety()
{return y;}
//mutators (setters)
public void setx(double a)
{x=a;}
public void sety(double b)
{y=b;}

//Distance from Origin, Assumed to be (0,0)
public double distFromOrg(){
return Math.sqrt(x*x+y*y);
}
//Distance between two Points
public double DistFromPoint(Point P){
return Math.sqrt((P.x-x)*(P.x-x)+(P.y-y)*(P.y-y));
}
//What Quadrant is the point object in
public int whatQuadrant(){
if (x>0 && y>0)
return 1;
else if(x<0 && y>0)
return 2;
else if(x<0 && y<0)
return 3;
else
return 4;}
//Slope between two points
public double slope(Point P){
return (P.y-y)/(P.x-x);
}
  
  
}
public class PPoint {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("please choose two coordinates for your first point"
+ " hittin enter after each one");
//3 points defined by the user of the progam
//Point 1
double Person=input.nextInt();
double Person2=input.nextInt();
Point P1= new Point(Person,Person2);
System.out.println();
//Point 2
double Person3=input.nextInt();
double Person4=input.nextInt();
Point P2= new Point(Person3,Person4);
System.out.println();
//Point 3
double Person5=input.nextInt();
double Person6=input.nextInt();
Point P3= new Point(Person5, Person6);
System.out.println();
  
}
  
}

Create a Java program called Point. This project will have Point.java as its file. The Point class will represent a point in 2-Dimensional space. – The Point class will have two instance variables: x and y. Both instance variables will have type double. Both instance variables will be private. - You will create two constructors: a default no argument con- structor and a constructor that takes two integers as arguments(representing x and y coordinates). – You will also create accessors(getters) and mutators(setters) methods for each instance variable. -You will then implement the following instance methods:

//Distance from Origin, Assumed to be (0,0)public double distFromOrg()

//Distance between two Points public double DistFromPoint(Point P)

//What Quadrant is the point object in public int whatQuadrant()

//Slope between two points public double slope(Point P)

Finally, in the main method(in the Point class) that does the following: –Creates 3 Point Objects, values of x and y coordinates can be defined by YOU. – Print the three Point objects to the console showing their x and y coordinates. – Compute the distance between two Point objects. Which two Point objects is up to you. Print the distance to the console. – Compute the distance between a Point object and the origin. Which Point object you used is up to you. Print the distance to the con- sole.– Compute the slop of a line passing through two point Objects. Which two Point objects is up to you. Print the slop the console.-Determine which quadrant all 3 Point objects are in. Print the quadrants to the console.

I have the code above already completed i just cant seem to figure out how to print out to the counsol what points the user chose and also need help with the rest wand how i make the program determine, for example the distance from the origin.

Explanation / Answer

--------------------------------------------------------------------------------------------------------------------------------------------------------

package ppoint;
import java.util.*;
public class Point{
    //instance variables
    private double x;
    private double y;
  
    //no argument constructor
    public Point(){
        x=0;
        y=0;
    }
    //constructor that takes two arguments
    public Point (double a, double b){
       x=a;
       y=b;
    }
    //accessors (getters)
    public double getx()
        {return x;}
    public double gety()
        {return y;}
    //mutators (setters)
    public void setx(double a)
        {x=a;}
    public void sety(double b)
        {y=b;}

    //Distance from Origin, Assumed to be (0,0)
    public double distFromOrg(){
    return Math.sqrt(x*x+y*y);
    }
    //Distance between two Points
    public double DistFromPoint(Point P){
    return Math.sqrt((P.x-x)*(P.x-x)+(P.y-y)*(P.y-y));
    }
    //What Quadrant is the point object in
    public int whatQuadrant(){
    if (x>0 && y>0)
        return 1;
    else if(x<0 && y>0)
        return 2;
    else if(x<0 && y<0)
        return 3;
    else
        return 4;}
    //Slope between two points
    public double slope(Point P){
    return (P.y-y)/(P.x-x);
    }
}

------------------------------------------------------------------------------------------------------------------------------------------------------------

package ppoint;

import java.util.Scanner;
public class PPoint {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      Scanner input= new Scanner(System.in);
      System.out.println("please choose two coordinates for your first point"
              + " hittin enter after each one");
    //3 points defined by the user of the progam
        //Point 1
        double Person=input.nextInt();
        double Person2=input.nextInt();
          Point P1= new Point(Person,Person2);
          System.out.println();
        //Point 2
        double Person3=input.nextInt();
        double Person4=input.nextInt();
          Point P2= new Point(Person3,Person4);
          System.out.println();
        //Point 3
        double Person5=input.nextInt();
        double Person6=input.nextInt();
          Point P3= new Point(Person5, Person6);
          System.out.println();
        
         System.out.println("--------------------------------------Location-------------------------------------------------");  
        System.out.println("X Coordinates: "+P1.getx()+" ;Y Coordinates: "+P1.gety());
        System.out.println("X Coordinates: "+P2.getx()+" ;Y Coordinates: "+P2.gety());
        System.out.println("X Coordinates: "+P3.getx()+" ;Y Coordinates: "+P3.gety());
        System.out.println(" ");  
          
        double dist1=P1.DistFromPoint(P2);
        double dist2=P1.DistFromPoint(P3);
        double dist3=P2.DistFromPoint(P3);
        System.out.println("---------------------------Distance Between Two Points-----------------------------------------");  
        System.out.println("Distance Between ("+P1.getx()+","+P1.gety()+") and ("+P2.getx()+","+P2.gety()+") = "+dist1);
        System.out.println("Distance Between ("+P1.getx()+","+P1.gety()+") and ("+P3.getx()+","+P3.gety()+") = "+dist2);
        System.out.println("Distance Between ("+P2.getx()+","+P2.gety()+") and ("+P3.getx()+","+P3.gety()+") = "+dist3);
        System.out.println(" ");  
      
        double dist4=P1.distFromOrg();
        double dist5=P2.distFromOrg();
        double dist6=P3.distFromOrg();
        System.out.println("---------------------------Distance with Origin--------------------------------------------------");  
        System.out.println("Distance Between ("+P1.getx()+","+P1.gety()+") and Origin = "+dist4);
        System.out.println("Distance Between ("+P2.getx()+","+P2.gety()+") and Origin = "+dist5);
        System.out.println("Distance Between ("+P3.getx()+","+P3.gety()+") and Origin = "+dist6);
        System.out.println(" ");  
      
      
        double slope1=P1.slope(P2);
        double slope2=P1.slope(P3);
        double slope3=P2.slope(P3);
        System.out.println("------------------------------Slope Between Two Points--------------------------------------------");  
        System.out.println("Slope Between ("+P1.getx()+","+P1.gety()+") and ("+P2.getx()+","+P2.gety()+") = "+slope1);
        System.out.println("Slope Between ("+P1.getx()+","+P1.gety()+") and ("+P3.getx()+","+P3.gety()+") = "+slope2);
        System.out.println("Slope Between ("+P2.getx()+","+P2.gety()+") and ("+P3.getx()+","+P3.gety()+") = "+slope3);
        System.out.println(" ");  
      
        int quad1=P1.whatQuadrant();
        int quad2=P2.whatQuadrant();
        int quad3=P3.whatQuadrant();
        System.out.println("-----------------------------------Point Quadrant--------------------------------------------------");  
        System.out.println("Point ("+P1.getx()+","+P1.gety()+") Exists in "+quad1);
        System.out.println("Point ("+P2.getx()+","+P2.gety()+") Exists in "+quad2);
        System.out.println("Point ("+P3.getx()+","+P3.gety()+") Exists in "+quad3);
        System.out.println(" ");
        }
}

-------------------TEST CASE OUTPUT-------------------------------

--------------------Configuration: <Default>--------------------
please choose two coordinates for your first point hittin enter after each one
1
-2

2
-8

1
8

--------------------------------------Location-------------------------------------------------
X Coordinates: 1.0 ;Y Coordinates: -2.0
X Coordinates: 2.0 ;Y Coordinates: -8.0
X Coordinates: 1.0 ;Y Coordinates: 8.0


---------------------------Distance Between Two Points-----------------------------------------
Distance Between (1.0,-2.0) and (2.0,-8.0) = 6.082762530298219
Distance Between (1.0,-2.0) and (1.0,8.0) = 10.0
Distance Between (2.0,-8.0) and (1.0,8.0) = 16.0312195418814


---------------------------Distance with Origin--------------------------------------------------
Distance Between (1.0,-2.0) and Origin = 2.23606797749979
Distance Between (2.0,-8.0) and Origin = 8.246211251235321
Distance Between (1.0,8.0) and Origin = 8.06225774829855


------------------------------Slope Between Two Points--------------------------------------------
Slope Between (1.0,-2.0) and (2.0,-8.0) = -6.0
Slope Between (1.0,-2.0) and (1.0,8.0) = Infinity
Slope Between (2.0,-8.0) and (1.0,8.0) = -16.0


-----------------------------------Point Quadrant--------------------------------------------------
Point (1.0,-2.0) Exists in 4
Point (2.0,-8.0) Exists in 4
Point (1.0,8.0) Exists in 1

Process completed.