Question: (Sides of a Triangle) Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the

(Sides of a Triangle) Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle.

Sample Run: Enterthreesizes,separatedbyspaces(decimalsvaluesareacceptable):4.55.53.5? Atrianglecouldmeasure4.50,5.50,by3.50.?

What I have so far, not working:

import java.util.*;

class TriangleYN

{

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

double a;

double b;

double c;

System.out.print("Enter three sizes, speparated by spaces(decimals values are acceptable):");

a = input.nextDouble();

b = input.nextDouble();

c = input.nextDouble();

if((a+b) > c)

{

if((a+c) > b)

{

if((b+c) > a)

{

System.out.printf("A triangle could measure %.2f, %.2f, by %.2f.", a, b, c);

return;

}

}

}

}

}

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!