1)-Write a Java program that reads values for three sides of a triangle. The sides will form a triangle if the values are greater than zero and the sum of any two sides is greater than the third side. The program should classify the triangle as either isosceles, scalene, equilateral, or both right-angled and scalene according to the following rules: • An equilateral triangle has all sides equal • An isosceles triangle has only two sides equal • A scalene triangle has no sides equal • In a right-angled triangle, the square of the longest side must be equal to the sum of the squares of the other two sides. (i.e., if c is the longest side among sides a, b and c of a right-angled triangle then c2 = a2 + b2

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

1)-Write a Java program that reads values for three sides of a triangle. The sides will form a
triangle if the values are greater than zero and the sum of any two sides is greater than the
third side. The program should classify the triangle as either isosceles, scalene, equilateral, or
both right-angled and scalene according to the following rules:
• An equilateral triangle has all sides equal
• An isosceles triangle has only two sides equal
• A scalene triangle has no sides equal
• In a right-angled triangle, the square of the longest side must be equal to the sum
of the squares of the other two sides. (i.e., if c is the longest side among sides a, b
and c of a right-angled triangle then c2 = a2 + b2
).

Here are some specific requirements:
• Include a boolean method named checkTriangle, which accepts three
double values as arguments and returns true if they form a triangle (otherwise
returns false)
• Include a value returning method named getLongest, which accepts three
double values as arguments and returns the largest value.
• Include a boolean method named checkRightTriangle, which accepts
three double values as arguments and returns true if they form a right angled
triangle (otherwise returns false)
Display an appropriate message indicating the type of triangle. Save the program as
Triangle.java. Extend the program so that it provides the user with an option to
continue running it.
Here are two sample runs:
Run 1:
Enter three sides (doubles): 1.0 1.0 10.0
Input is invalid. Triangle cannot be formed.
Do you want to run the program again? (Y/N)
N
Run2:
Enter three sides (doubles): 3.0 4.0 5.0
This is a right-angled scalene triangle
Do you want to run the program again? (Y/N)
Y
Enter three sides (doubles): 5.0 5.0 4.0
This is an isosceles triangle
Do you want to run the program again? (Y/N)
N

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education