Share
Explore BrainMass

Java Rectangle Class

(Rectangle Class) Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has methods that calculate the perimeter and the area of the rectangle. It has set and get methods for both length and width. The set methods should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. Write a program to test class Rectangle.

Solution Preview

I have attached the .java codes as well as the .class file for calculating the perimeter and area of a rectangle.
Just for review, for a rectangle ...

Solution Summary

Create a class Rectangle.

$2.19