Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(IN JAVA) If the triangle is a right-angled triangle, the relationship between the sides of the triangle is as follows: c = (a2 + b2)

(IN JAVA)

If the triangle is a right-angled triangle, the relationship between the sides of the triangle is as follows:

c = (a2 + b2) where c is the hypotenuse.

Write a program that can test whether a triangle is right-angled or not. The program begins by reading from the user three (double-typed) numbers representing the three sides of a triangle. The user can enter the three sides in any order and the largest number is considered as the hypotenuse. Then, the program displays Yes, this is a right-angled triangle. if it is a right-angled triangle or NO, this is not a right-angled triangle. otherwise. Next, the program will ask the user whether to continue with the next set of inputs. If the user wants to continue, the program will repeat to do the same thing for the next three numbers. Otherwise, the program will stop reading and it will display the total number of right-angled triangles that the user has entered.

An example of the programs running is given below (Note: The bold texts below are inputs entered by the user) Enter the three sides of a triangle> 5 3 4 Yes, this is a right-angled triangle. Do you want to continue? (y/n)> y Enter the three sides of a triangle> 12 13 5 Yes, this is a right-angled triangle. Do you want to continue? (y/n)> y Enter the three sides of a triangle> 92 43 96 No, this is not a right-angled triangle. Do you want to continue? (y/n)> n The total number of right-angled triangle = 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions