Ask Question
10 April, 00:13

Write a program that reads three edges 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 edges is greater than the remaining edge.

+5
Answers (1)
  1. 10 April, 03:52
    0
    The program is given in the explanation section

    Explanation:

    import java. util. Scanner;

    public class num5 {

    public static void main (String[] args) {

    Scanner in = new Scanner (System. in);

    System. out. println ("Enter the three edges of the triangle");

    double sideA = in. nextDouble ();

    double sideB = in. nextDouble ();

    double sideC = in. nextDouble ();

    if (sideA < sideB + sideC && sideB < sideA + sideC && sideC < sideA + sideB) {

    double perimeter = sideA+sideB+sideC;

    System. out. println ("perimeter: "+perimeter);

    }

    else{

    System. out. println ("Invalid inputs");

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a program that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers