Doing an interesting problem that I've found on the net, I'm gonna give it a shot. Can you guys do it as well? I wanna compare my code to yours. Especially if I don't get the code right, I wanna find out and learn where I went wrong.

Quote:

Triangles can be classified in a number of ways by considering the relative sizes of either their

sides or their angles.

Side Classifications:

1. equilateral – all sides are equal

2. isosceles – exactly two sides are equal

3. scalene – no sides are equal

Side classifications are done by comparing the length of the three sides of the triangle.

Angle Classifications:

1. right – the largest angle is a right angle (i.e., 90°)

2. acute – the largest angle is less than a right angle

3. obtuse – the largest angle is greater than a right angle

If the three sides of a triangle are known, the Pythagorean Theorem can be used to classify the

triangle as right, obtuse, or acute.

Recall: The Pythagorean Theorem states that, in a right triangle, the square of the largest side is

equal to the sum of the squares of the other two sides. As an equation,

c2=a2b2

If the triangle is not a right triangle, this relationship can still be used to determine if the triangle is

acute or obtuse.

Problem Statement

Write a program that will read an arbitrary number of sets of triangle sides using only integer

values. The program should:

1. Prompt the user for sets of numbers and process them until the user submits the numbers

0 0 0, which will terminate the program.

2. For each set of three numbers, the program should print the values read.

3. For each set of three numbers, the program should decide if the numbers represent the

sides of a valid triangle.

4. If the numbers could not represent a valid triangle, display an appropriate error message.

5. If the numbers are valid, the program should determine, and display, the:

(a) side classification of the triangle – equilateral, isosceles, or scalene

(b) angle classification of the triangle – right, acute, or obtuse

ICS3x Assignment – Methods – Triangle Classification Nov 24, 2010

Sample Input & Output

Input from the user is indicated by bolded text.

Provide three side lengths – 0 0 0 to terminate.

3

5

4

3 5 4 Triangle possible: scalene and right.

Provide three side lengths – 0 0 0 to terminate.

5

2

5

5 2 5 Triangle possible: isosceles and acute.

Provide three side lengths – 0 0 0 to terminate.

-7

1

2

-7 1 2 Triangle cannot be formed.

Provide three side lengths – 0 0 0 to terminate.

0

0

0

0 0 0 Program was terminated by user.

(You can only use input/output, calculations, variables, decisions, and loops)