Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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]
a) Draw the CFG of the program and calculate the full complexity. (Use code below)
image text in transcribed
int main() i 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(): b= input.nextint(i): c=input.nextint(): if (a+b=cabs(ac)>ababs(bc)>=a) 1 System out. printin("The three sides cannot form a triangle"): else t if (a=ba=cb=c) 1 if (a=b&&b=ac) 1 System.out.printin("Equilateral triangle"): 1 else t System.out. printin("Isosceles triangle"); 1 ) else 1 + System.out. printin("common triangle"); I return 0; J

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions