Computer Science, asked by prateeks6656, 1 year ago

WAP a program to enter 3 sides of triangle and check wHethersett the triangle is possible or not. If possible then display whether it is an equilateral using scanner

Answers

Answered by sswaraj04
1

Answer:

import java.util.Scanner;

public class triangle{

   public static void main(String[] args) {

       Scanner sc=new Scanner(System.in);

       int a,b,c;

       System.out.println("enter  side 1");

       a=sc.nextInt();

       System.out.println("enter  side 2");

        b=sc.nextInt();

        System.out.println("enter  side 3");

        c=sc.nextInt();

        if(a<=0||b<=0||c<=0)

        System.out.println("sides should be positive...Not possible");

       if((a+b)<c||(a+c)<b||(b+c)<a)

       System.out.println("not possible");

       else if(a==b&&b==c)

       System.out.println("it's an equilateral triangle");

       else

       System.out.println("possible but not equilateral");

}}

Similar questions