Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class called RightTriangle with the following members: Fields: sideA , a double variable to store length of side A. sideB , a double

Create a class called RightTriangle with the following members:

Fields:

sideA, a double variable to store length of side A.

sideB, a double variable to store length of side B.

R_ANGLE, an integer constant to store value of right angle which is 90.

count, a static integer variable to store the number of created objects.

Methods:

side A

RightTriangle, a constructor that gets two double inputs and assigns them to sideA and sideB. The constructor needs to update the number of objects when an object is created.

setSideA, a set method to assign a value to sideA.

setSideB, a set method to assign a value to sideB.

getSideA, a get method to return the value of sideA.

getSideB, a get method to return the value of sideB.

getCount, a static method to return the number of created objects.

hypotenuse, a method that calculates and returns the length of hypotenuse using following

formula:

h?????????????????? = ???????????2 + ??????????2

Note: Import all static members of Math class in RightTriangle class and use pow and sqrtmethods of Math class to calculate hypotenuse.

toString, a method to return a string containing all information for an object (the number of created object, side A, side B, hypotenuse, and right angle).

Note: You need to call hypotenuse method in this method

The RightTriangleTest Class

Then create a driver class called RightTriangleTest. In the main method of this class create 3 objects of RightTriangle class using your defined constructor. After creating each object use System.out.printf to display information of that object.

side B

Sample Output

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

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

Describe positive and neutral messages.

Answered: 1 week ago

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago