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, triangle1, using the default constructor
b. Creates a Triangle object, triangle2, using these values: 3,4,5
c. Gets the perimeter and area of triangle 1 using the corresponding methods
and prints them out, using 3 decimals for the area
d. Gets the perimeter and area of triangle2 using the corresponding methods
and prints them out, using 3 decimals for the area 2) A class named
Triangle, which contains:
a. Three integer data fields named side1, side2 and side3- the sides of the
triangle
b. A no-arg constructor that creates a default triangle where all sides are of
length 1.
c. A constructor that takes 3 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 3 sides.
Sample run:
triangle1 perimeter is 3, area is 0.433
triangle2 perimeter is 12, area is 6.000
Instructions: Write a Java program that has a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!