Ask Question
23 June, 02:55

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.

+3
Answers (1)
  1. 23 June, 04:22
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers