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.

Respuesta :

ijeggs

Answer:

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");

    }

   }

}

Three edges for a triangle :

A triangle is a polygon with three edges and three vertices. It is one of the basic shapes in geometry. A triangle with vertices A, B, and C. The length of the sides of a triangle may be the same or different. If all the 3 sides of a triangle are equal then it is an equilateral triangle.

The required codes are:

import java.io.*;import java.util.Scanner;class Perimter{public static void main(String args[]){ int a,b,c; a=0;b=0;c=0;Scanner sc=new Scanner(System.in);System.out.println("Enter side 1 value"); a=sc.nextInt(); System.out.println("Enter side 2 value"); b=sc.nextInt(); System.out.println("Enter side 3 value"); c=sc.nextInt(); int p=a+b+c; if((a+b&amp;gt;=c)&amp;amp;&amp;amp;(a+c&amp;gt;=b)&amp;amp;&amp;amp;(b+c&amp;gt;=a)){ System.out.println("Permiter of the triangle"+p);} else{ System.out.println("Invalid Input"); }}}I have executed the code in the online compiler. Please execute it under the offline compiler.Input:122

Learn more about the topic program that reads three edges for a triangle:

https://brainly.com/question/25327642