-
Notifications
You must be signed in to change notification settings - Fork 0
/
Point.java
43 lines (31 loc) · 1.17 KB
/
Point.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.Scanner;
public class Point {
Double width;
Double height;
Scanner s = new Scanner(System.in);
public Point(Double width, Double height){
this.width = width;
this.height = height;
}
public Point middle(Point p){
Point y = new Point(4.0,15.0);
Point x = new Point(s.nextDouble(),s.nextDouble());
double width = (y.width + x.width) / 2;
double height = (y.height + x.height) / 2;
Point z = new Point(width,height);
return z;
}
public Double distance(Point p){
Point y = new Point(4.0,15.0);
Point x = new Point(s.nextDouble(),s.nextDouble());
return Math.sqrt(Math.pow((x.height - y.height),2) + Math.pow((x.width - y.width),2));
}
public Double areaSize(Point x, Point y) {
Point z = new Point(s.nextDouble(),s.nextDouble());
return(x.width*(y.height - z.height) + y.width * (z.height - x.height) + z.width * (x.height - y.height))/2;
}
public Double slope(){
Point x = new Point(s.nextDouble(),s.nextDouble());
return (x.height / x.width);
}
}