Question: Q4. Consider the following program, and judge whether the three integer side lengths can form a triangle. This triangle can be general triangle, an isosceles
Q4. Consider the following program, and judge whether the three integer side lengths can form a triangle. This triangle can be general triangle, an isosceles triangle or an equilateral triangle, and finally outputs the triangle type. [Note: The sum of the two sides is greater than the third side, and the absolute value of the difference between any two sides is less than the third side. It can form a triangle] 1. a=1,b=2,c=5 2. a=4,b=5,c=3 3, a=3,b=3,c=4 4. a=3,b=3,c=3 int maino : Scanner input-new Scanner(System.in); int a,b,c; System.out.printin("Please enter the length of the three sides of the triangle (CM): "); a-input.nextInt 0 : b=input.nextInt 0 ; c=input.nextInt 0 ; if (a+b=cabs(ac)>=babs(bc)>=a) System.out.println("The three sides cannot form a triangle"); \} else : if (a=ba=cb=c){ if (a=b&&b=c) \} System.out.printin("Equilateral triangle"); \} clse : System.out.printin("Isosceles triangle"); | \} else \{ System.out.println("common triangle"); } \} return 0; 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
