Ask Question
30 March, 00:06

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. 30 March, 00:10
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers