
write a program that reads three edges for a tringle and determines
whether the input valid. the input is valid if the sum of any two edges
is greater thyan the third edge.for example, if your input for three
edges is 1,2,1 output should be: can edges 1,2 and 1 from a triangle? false

Hi Friend,
Try this:
import java.util.*;
class Triangle
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter edge1: ");
int e1=input.nextInt();
System.out.print("Enter edge2: ");
int e2=input.nextInt();
System.out.print("Enter edge3: ");
int e3=input.nextInt();
int n=e1+e2;
boolean check=false;
if(e3==n){
check=true;
}
else{
check=false;
}
System.out.println("can edges "+e1+","+e2+" and "+e3+" from a triangle? "+check);
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.