Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

- Create a Java program called Test Triangle. Inside this program, implement the class Triangle as shown in the UML Class diagram above. - You

image text in transcribedimage text in transcribedimage text in transcribed

- Create a Java program called "Test Triangle". Inside this program, implement the class "Triangle" as shown in the UML Class diagram above. - You must implement the "Triangle" class strictly according to its UML oneto-one (do not include anything extra, do not miss any data fields or methods). - The method isRightAngled returns true if the triangle is a right angled, otherwise it returns false. - The logic for checking a right-angled triangle is: "Sum of squares of two small sides (adjacent and opposite) should be equal to the square of the longest side (hypotenuse)" - Add comments to your program (mark where data fields, constructors, getters, setters, methods, toString ( are) - Create two Triangle objects: one using no-args (i.e., default) constructor and one from the constructor with all fields. (i.e., overloaded) - Print the contents of both objects using toString( method. i. The program should randomly pick a number between 1 to 15 and store it. ( 2 points) ii. The program should then create an array of triangle objects equal to the random number. ( 2 points) iii. The program should construct the triangle objects in the array by invoking the overloaded constructor. (4 points) iv. The program should randomly assign values for the data fields in range 10 to 50. ( 1 points) v. The program should then display the total number of triangle objects created by invoking the getNumOfTriangles() method. (3 points). vi. The program should then display the values of opposite side, adjacent side and hypotenuse only for those triangle objects that are right-angled. If none of the triangle objects are right-angled, it should display a message "There is no right-angled triangles in the object array". (6 points) SUBMISSION: Please submit only the JAVA file "TestTriangle.java

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

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

What is the purpose of brand management?

Answered: 1 week ago

Question

5. Our efficiency focus eliminates free time for fresh thinking.

Answered: 1 week ago