作业帮 > 综合 > 作业

class Point{ public double x,y; Point(double x,double y){ th

来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/12 06:01:58
class Point{ public double x,y; Point(double x,double y){ this.x=x; this.y=y; } static void show(){
老是出错,感激不尽
class Point{
public double x,y;
Point(double x,double y){
this.x=x;
this.y=y;
}
static void show(){
System.out.println("x="+x+" ");
System.out.println("y="+y+" ");
}
}
public class Point1{
public static void main(String[] args){
Point p1=new Point(15,18);
Point p2=new Point(12,16);
new Point(p1,p2);
p1.show();
p2.show();
getMiddle()
{x=(p1.x+p2.x)/2;
y=(p1.y+p2.y)/2;
Point.show();
}
}
}
class Point{ public double x,y; Point(double x,double y){ th
class Point{
public double x,y;
Point(double x,double y){
this.x=x;
this.y=y;
}
void show(){
System.out.println("x="+x+" ");
System.out.println("y="+y+" ");
}
}
public class Point1{
public static void main(String[] args){
Point p1=new Point(15,18);
Point p2=new Point(12,16);
p1.show();
p2.show();
Point p3=getMiddle(p1,p2);
p3.show();
}
static Point getMiddle(Point p1,Point p2)
{
\x05 double x=(p1.x+p2.x)/2;
double y=(p1.y+p2.y)/2;
return new Point(x,y);
}
}