Question: Please include a while loop that using the Scanner method that keeps prompting until you input a positive number for the triangle's sides. Write a

 Please include a while loop that using the Scanner method that

Please include a while loop that using the Scanner method that keeps prompting until you input a positive number for the triangle's sides.

Write a program named that asks for the lengths of the three sides of a triangle and computes the perimeter if the input is valid. The input is valid if the sum of every pair of two sides is greater than the remaining side. For example, the lengths 3,4 , and 5 define a valid triangle: 3 plus 4 is greater than 5 ; 4 plus 5 is greater than 3 , and 5 plus 3 is greater than 4 . However, the lengths 7.2,2.4, and 4 do not specify a valid triangle because 2.4 plus 4 is not greater than 7.2. Here is the output from running the program twice. Your program's output does not have to look exactly like this, but it must convey the same information. User input is shown in bold. Enter lengths of sides of the triangle: 345 The perimeter of the triangle is 12.0 Enter lengths of sides of the triangle: 7.22 .44 Those sides do not specify a valid triangle

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!