Given the code below public class Rectangle { private double length; private double width; // setters and
Question:
Given the code below
public class Rectangle {
private double length;
private double width;
// setters and getters
public double getLength(){???}
public void setLength(???){???}
public double getWidth(){???}
public void setWidth(???){???}
// object method
????calculateArea(){????}
????isSquare(){????}
}
a. Complete the appropriate Getter methods.
b. Complete the appropriate Setter methods - including the parameters required
c. Complete a method so that the method calledcalculateArea() returns the area of the rectangle.
d. Complete a method so that the method calledisSquare() returns true if width is equal to length, otherwise return false.
e. Create an object obj and set its length as 10 and width as 7. Print its area and tell if it is a square.
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne