Question: Write a program that reads three sides for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is
Write a program that reads three sides for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of every pair of two sides is greater than the remaining side. Here is a sample:
| This program calculates the perimeter of a triangle. Enter the length of the three sides with a comma between them: 1, 1, 1 The perimeter is 3. This program calculates the perimeter of a triangle. Enter the length of the three sides with a comma between them: 1, 3, 1 The input is invalid. |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
