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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started