JAVA PLEASE Starting with your solution to the previous task, add the following methods to your ScaleneTriangle class to extend its functionality. A default (or "no-argument" or "no-arg") constructor that constructs a Triangle object using default values. An overloaded constructor that constructs a Triangle object with the given values. A method named getArea() which returns the area of a triangle. This method returns a double. The are is calculated by: √(s * (s - sideA) * (s - sideB) * (s - sideC)) where s = (sideA + sideB + sideC) / 2 Write the ScaleneTriangle class in the answer box below assuming that the superclass is given. For example:
JAVA PLEASE
Starting with your solution to the previous task, add the following methods to your ScaleneTriangle class to extend its functionality.
- A default (or "no-argument" or "no-arg") constructor that constructs a Triangle object using default values.
- An overloaded constructor that constructs a Triangle object with the given values.
- A method named getArea() which returns the area of a triangle. This method returns a double. The are is calculated by: √(s * (s - sideA) * (s - sideB) * (s - sideC)) where s = (sideA + sideB + sideC) / 2
Write the ScaleneTriangle class in the answer box below assuming that the superclass is given.
For example:
abstract class Triangle {
protected double sideA;
protected double sideB;
protected double sideC;
public Triangle() {
sideA = sideB = sideC = 10;
}
public Triangle(double sideA, double sideB, double sideC) {
this.sideA = sideA;
this.sideB = sideB;
this.sideC = sideC;
}
public double getSideA() {
return sideA;
}
public double getSideB() {
return sideB;
}
public double getSideC() {
return sideC;
}
public abstract double getArea();
public double getPerimeter() {
return sideA + sideB + sideC;
}
public String toString() {
return
String.format("%s:(%.2f, %.2f, %.2f)",
getClass().getName(), sideA, sideB, sideC);
}
}
![Test
ScaleneTriangle t1 = new ScaleneTriangle();
System.out.printf("%s, perimeter=%.2f,
area= %.2f\n", t1.toString(), t1.getPerimeter (),
t1.getArea());
System.out.println(t1 instanceof Triangle);
ScaleneTriangle t1 = new ScaleneTriangle(2.0,
3.0, 4.0);
ScaleneTriangle t2 = new ScaleneTriangle();
System.out.printf("%s, perimeter=%.2f,
area= %.2f\n", t1.toString(), t1.getPerimeter (),
t1.getArea());
System.out.printf("%s, perimeter=%.2f,
area= %.2f\n", t2.toString(), t2.getPerimeter(),
t2.getArea());
Result
ScaleneTriangle: (10.00, 10.00,
10.00), perimeter=30.00,
area=43.30
true
Scalene Triangle: (2.00, 3.00,
4.00), perimeter=9.00,
area=2.90
Scalene Triangle: (10.00, 10.00,
10.00), perimeter=30.00,
area=43.30](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F5e781105-97d2-4c44-bb9e-d30534019737%2Fc34c22d9-8b41-49cd-9d91-a37ff3b165b8%2F28loe2q_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)