Question: Instructions: Write a Java program that has a single module with two classes: A public class that contains the main method, which does the following:
Instructions: Write a Java program that has a single module with two classes:
A public class that contains the main method, which does the following:
a Creates a Triangle object, triangle using the default constructor
b Creates a Triangle object, triangle using these values:
c Gets the perimeter and area of triangle using the corresponding methods
and prints them out, using decimals for the area
d Gets the perimeter and area of triangle using the corresponding methods
and prints them out, using decimals for the area A class named
Triangle, which contains:
a Three integer data fields named side side and side the sides of the
triangle
b A noarg constructor that creates a default triangle where all sides are of
length
c A constructor that takes integers, each corresponding to a side in the
triangle.
d Setter and Getter methods for the length of each side of the triangle
e A method named getPerimeter that returns the perimeter of the triangle
as an integer
f A method named getArea that returns the area of the triangle as a
double using the methodology described in this website: Area of Triangle
with sides.
Sample run:
triangle perimeter is area is
triangle perimeter is area is
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
