Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class called Triangle that represents a triangle It has three double precision instance variables representing the three sides Write a constructor for Triangle

image text in transcribed
Write a class called Triangle that represents a triangle It has three double precision instance variables representing the three sides Write a constructor for Triangle objects that takes three double precision values The lengths of sides a. b. and c are double precision and expected to be greater than zero. However, the user might supply bad data Accept whatever values the user provides The lengths are not in any particular order (don't assume that a is the smallest or largest.) Include the following methods that return Boolean values indicating if the particular property holds. Give your methods exactly these names public Three sides make a triangle if the sum of two sales a greater than the third sale This must be true for al three combinations of sides For the other "is" methods, immediately return false 4 the sides do not make up a legitimate triangle Use Is Triangle () to test this Otherwise, continue testing the relevant property Use the Pythagorean Theorem to determine if a triangle is a right triangle A triangle is isosceles 4 two or three sales are the same length (Sometimes isosceles is taken to mean two sides the same and the third different) Also include a method area() which calculates and returns the area of the triangle (as a double precision value) Return -1 if the object a not a triangle Include a to string() method that returns a String based on the object public double areal) (use Herons formula from program 3) public String to String () You don't need to use NunterFornar with the toStr mg () method (although you can do this if you want) Use Blue J to develop and For this project there be no method There will be no System.out.; tint statements since al user interaction wd be through BlueJ After your source fUe corrpdes. you wfl be able (m BlueJ) to click on the rectangle that represents the class to instantiate 4. Now a red rectangle should appear that represents an object Clidung and selecting methods of the object should now work Instantiate several Triangles with various sides and verify that your class works correctly Start your source fie with comments that describe it

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

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions

Question

How do you define Big Data? Why is it difficult to define?

Answered: 1 week ago

Question

Name the different types of values.

Answered: 1 week ago

Question

=+Do you have any disabilities?

Answered: 1 week ago