Computer Science, asked by rkumari65192, 1 day ago

computer
Write a program to accept three sides of a triangle and check whether triangle is possible or not.
(Hint : the sum of any two sides of a triangle is greater than the third side)​

Answers

Answered by reenaabhishekpatelsa
1

Answer:

Here is the program.

import java.util.*;

public static void main(String[] args) { Scanner sc=new Scanner(System.in);

double a, b, c; System.out.print("Enter first side: "); ...

if(a+b>c && b+c>a && a+c>b) { ...

if(a==b && b==c) System.out.println("Triangle is Equilateral Triangle.");

else if(a==b || b==c || c==a) ...

else.

Answered by r27272278
0

\huge\fcolorbox {magenta} {pink} {Hey mate here is the answer}

import java.io.*;

public class KboatTriangle

{

public static void main(String args[]) throws IOException {

InputStreamReader read = new InputStreamReader(System.in);

BufferedReader in = new BufferedReader(read);

System.out.print("Enter first angle: ");

int a = Integer.parseInt(in.readLine());

System.out.print("Enter second angle: ");

int b = Integer.parseInt(in.readLine());

System.out.print("Enter third angle: ");

int c = Integer.parseInt(in.readLine());

int sum = a + b + c;

if(a != 0 && b != 0 && c != 0 && sum == 180) {

if((a + b) >= c || (b + c) >= a || (a + c) >= b) {

System.out.println("Triangle is possible");

}

else {

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

}

}

else {

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

}

}

}

Output :

Enter first angle : 50

Enter second angle : 60

Enter third angle : 70

Traingle is possible

Similar questions