Computer Science, asked by ridhimasarawgi1, 8 months ago

Write a class Trianglearea that contains the overloaded methods area,one that accepts the base and the height of a triangle as a parameter.The other area method accepts the length of three sides of a triangle.(java program)​

Answers

Answered by subhaspally351
6

class TriangleArea

{ double area1, area2 ;

int s;

public void area ( int base, int height)

{

area1 = 0.5*base*height ;

System.out.println ("Area 1 : " + area1);

}

public void area ( int a, int b, int c)

{

s = (a+b+c)/2;

area2 = Math.sqrt (s*(s-a)*(s-b)*(s-c)) ;

System.out.println ("Area 2 : " + area2);

}

public static void main(String args[])

{

TriangleArea ob = new TriangleArea();

ob.area();

ob.area();

}

}

Similar questions