Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Answer questions below by writing a Java program for each of the questions. 2. A right-angled triangle is a triangle in which one angle

Instructions: Answer questions below by writing a Java program for each of the questions.

image text in transcribed

2. A right-angled triangle is a triangle in which one angle is a right angle (90 degrees) and the largest side is called hypotenuse, c (refer to figure below). 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 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 rightangled triangle or "NO, this is not a right-angled triangle." otherwise. If all the three numbers entered by the user are equal, then the program will ask the user to re-enter the three values. Next, the program will ask the user whether to continue with the next set of 3 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. Finally, it will display the total number of right-angled triangles that the user has entered. An example of the program's running is given below (Note: The bold texts below are inputs entered by the user) Enter the three sides of a triangle> 534 Yes, this is a right-angled triangle. Do you want to continue? (y)>y Enter the three sides of a triangle> 121351 No, this is not a right-angled triangle. Do you want to continue? (y)>y Enter the three sides of a triangle> 12135 Yes, this is a right-angled triangle. Do you want to continue? (y)>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

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

14. In Prob. 13 find the BAS.

Answered: 1 week ago