Question: Create a class with a name of Rectangle. The class should have two instance fields that are of type double named width and height. Make

Create a class with a name of Rectangle. The class should have two instance fields that are of type double named width and height. Make these fields publically accessible. Also include a method named getArea() that returns the area (width * height) of the rectangle (return type double). Also include a method called getPerimeter that returns the perimeter ((width + height) * 2) of the rectangle (return type double).

Create another class called Control that will have the public static void main(String[] args) method. Within that method create an instance of Rectangle. Set the values of width and height for the instance just constructed to 4 and 5 respectively. Print out the area and perimeter of the rectangle. Run the Control class.

Programming to use is Java

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 Databases Questions!