0% found this document useful (0 votes)
8 views4 pages

003

Uploaded by

ANH nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views4 pages

003

Uploaded by

ANH nguyen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

import java.util.

Scanner;

class point{

double x,y;

point() {

x=0;

y=0;

point(int i, int j)

this.x=i;

this.y=j;

point(point p)

this.x=p.x;

this.y=p.y;

}}

class tamgiac{

final static int soluongdinh=3;

point d1 = new point();

point d2 = new point();

point d3 = new point();

void khoitaokhongthamso(){

d1.x=0;

d1.y=0;

d2.x=0;

d2.y=0;

d3.x=0;

d3.y=0;
}

void khoitaocothamso(point d1 ,point d2, point d3){

this.d1=d1;

this.d2=d2;

this.d3=d3;

double chuvi(){

double a,b,c,e,d,f,k;

a=d1.x-d2.x;

b=d2.x-d3.x;

c=d3.x-d1.x;

d=d1.y-d2.y;

e=d2.y-d3.y;

f=d3.y-d1.y;

k=Math.sqrt(a*a+b*b+c*c+d*d+e*e+f*f);

return Math.ceil(k);

tamgiac sosanhtamgiac(tamgiac b){

tamgiac a= new tamgiac();

a.d1=d1;

a.d2=d2;

a.d3=d3;

if(a.chuvi()>b.chuvi()){

System.out.println("tam giac co toa do "+d1.x);

return a;

}else

return b;

}
void gapn(float n , tamgiac a)

a.d1.x=a.d1.x*n;

a.d1.y=a.d1.y*n;

a.d2.x=a.d2.x*n;

a.d2.y=a.d2.y*n;

a.d3.x=a.d3.x*n;

a.d3.y=a.d3.y*n;

void xuat(){

System.out.println("tam giac co toa do dinh 1 : "+d1.x+(";")+d1.y);

System.out.println("tam giac co toa do dinh 2 : "+d2.x+(";")+d2.y);

System.out.println("tam giac co toa do dinh 3 : "+d3.x+(";")+d3.y);

System.out.println( "chu vi tam giac"+chuvi());

class buoi6{

public static void main(String[] args) {

tamgiac a = new tamgiac();

Scanner ip=new Scanner(System.in);

System.out.println("nhap toa do x dinh 1 ");

a.d1.x=ip.nextDouble();

System.out.println("nhap toa do y dinh 1 ");

a.d1.y=ip.nextDouble();

System.out.println("nhap toa do x dinh 2 ");

a.d2.x=ip.nextDouble();

System.out.println("nhap toa do y dinh 2 ");


a.d2.y=ip.nextDouble();

System.out.println("nhap toa do x dinh 3 ");

a.d3.x=ip.nextDouble();

System.out.println("nhap toa do y dinh 3 ");

a.d3.y=ip.nextDouble();

tamgiac b =new tamgiac();

b.d1= new point(0, 0);

b.d2= new point(5,0 );

b.d3=new point(5,6);

a.xuat();

b.xuat();

tamgiac z = a.sosanhtamgiac(b);

b.gapn(2, b);

b.xuat();

You might also like