Question
C4.3. (In Java) Design a public class named Rectangle to represent a rectangle. The class contains: double data fields width and length with default values
C4.3. (In Java) Design a public class named Rectangle to represent a rectangle. The class contains:
double data fields width and length with default values of 2 for width and 3 for length
Two constructor methods: o A no-argument contructor that creates a default rectangle o A contructor that creates a rectangle with the specified width and length in the formal parameters
A method named getPerimeter() that returns the perimeter
A method named getArea() that returns the area
Write a simple test program like we did in class that creates two Rectangle objects:
rect1 with default values for width and length
rect2 with width = 3.5 and length = 6.3
Display the perimeter and area of each rectangle.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started