✨ Help out please... Write a program in JAVA.. ✨
Attachments:
Anonymous:
???
Answers
Answered by
40
Java is a machine independent language which can work on any platform. Its an object oriented programming which stress on object rather than data.
The main parts while doing Java programming are package, Class ,input variables, condition updating.
FUNCTIONS:-
Its a program module used at different instances in a program to perform specific task.
◼First we need to check whether the triangle is possible.
◼If triangle is possible than check which triangle it is.
import java . io . *;
class triangle
{
public void poss(int p , int q ,int r)
{
int l,m,n:
if(p>q&&p>r)
{
if((p*p = q*q + r*r)=true))
return(1);
}
else if(q>p&&q>r)
{
if((q*q = p*p + r*r)=true))
return(2);
}
else if(r>q&&r>p)
{
if((r*r = q*q + p*p)=true))
return(3);
}
else
return(0);
}
public void decide(int x ,int y ,int z)
{
if(x==b&&y==c)
System . out . println("EQUILATERAL TRIANGLE")
if(x==y||y==z||z==x)
System . out . println("ISOSCELES TRIANGLE")
if(x!=y && y!=z &&z!=x)
System . out . println("SCALENE TRIANGLE")
}
public static void main(String args[])throws Exception
{
int a , b ,c;
DataInputStream in=new DataInputStream(System . in);
a=Interger.parseInt(in . readLine());
b=Interger.parseInt(in . readLine());
c=Interger.parseInt(in . readLine());
triangle obj=new triangle();
s=obj . poss(a,b,c);
if(s==1||s==2||s==3)
obj . decide(a,b,c);
else
System . out . println("Triangle isnt possible");
}
}
◼a = 5
b =6
c=9
since c is greater
9 *9 =5 *5 + 6* 6
81 = 25 + 36
81 = 71
Triangle is not possible.
◼a = 5
b = 4
c = 3
Since , a is greater
a*a = b*b + c*c
5 *5 = 4*4 + 3*3
25 = 16 +9
25 = 25
so,
Since , a is neither equal to b and c
SCALENE TRIANGLE
Similar questions