Write a program Triangle.java that determines the type of triangle from its 3 sides. Your program should prompt the user to enter integer lengths of the 3 sides of the triangle and then report the triangle type. An equilateral triangle has all sides the same, an isosceles triangle has only 2 sides that are the same, and a scalene triangle has all sides of different length. You must write & use a public static method triangleType that accepts the 3 side lengths (all type int) and returns a string that is the triangle type (the returned string should be one of “equilateral",“isosceles", or “scalene"). The main method you will write should prompt the user to enter the 3 lengths and read them in. It should then print "The triangle is" followed by the string returned from calling the triangleType method. See the sample executions below. Note: the method triangleType does not print any results to the screen but rather returns a string to the caller. The method triangleType should return "invalid values!" if any side has a non-positive value or if the three sides cannot form a triangle (such as when one side’s length is greater than or equal to the sum of the other two sides). Еxamples: This is a sample program execution to show you how Triangle.java should behave: This program will E your job to write ... ======= ==== ==== (Execution 1) Enter lengths of 3 sides of triangle: 5 That triangle is equilateral
Write a program Triangle.java that determines the type of triangle from its 3 sides. Your program should prompt the user to enter integer lengths of the 3 sides of the triangle and then report the triangle type. An equilateral triangle has all sides the same, an isosceles triangle has only 2 sides that are the same, and a scalene triangle has all sides of different length. You must write & use a public static method triangleType that accepts the 3 side lengths (all type int) and returns a string that is the triangle type (the returned string should be one of “equilateral",“isosceles", or “scalene"). The main method you will write should prompt the user to enter the 3 lengths and read them in. It should then print "The triangle is" followed by the string returned from calling the triangleType method. See the sample executions below. Note: the method triangleType does not print any results to the screen but rather returns a string to the caller. The method triangleType should return "invalid values!" if any side has a non-positive value or if the three sides cannot form a triangle (such as when one side’s length is greater than or equal to the sum of the other two sides). Еxamples: This is a sample program execution to show you how Triangle.java should behave: This program will E your job to write ... ======= ==== ==== (Execution 1) Enter lengths of 3 sides of triangle: 5 That triangle is equilateral
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
Related questions
Question
Computer
Expert Solution
Step 1
NOTE: Code run successfully. Please use proper indentation for no error. I have attached source code screenshot and output screenshot for your understanding follow them. you should save your file with main.java as the class name.
Algorithm:
- Take user input for three sides
- read the input
- use if else statement to compare the sides
- print the result in the end
- exit
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education