a) Create a class named Rectangle with fields named length, width, area and perimeter.
b) Add a constructor that takes no argument and sets the length and width to 1.
Add methods named setLength(), getLength() that set and return the length respectively.
d) Add methods named setWith(), getWidth() that set and return the width respectively.
e) Add a method computePerimeter(), which computes a and returns rectangle's perimeter.
f) Add a method computeArea() which computes and returns a rectangle's area.
[Hint Area = Lengh x Width ; Perimeter = 2(Length + Width)]
g) Create a class named TestRectangle whose main() method declares two Rectangle objects.
h) Using the setLength() method, assign one Rectangle object a Length of 2.5cm and assign another a Length of 4.5cm.
i) Using the setWidth() method, assign one Rectangle object a width of 1.5cm and assign another a width of 2.5cm.
j) Call computePerimeter() and computeArea() for each rectangle and display the results.
1
Expert's answer
2012-12-19T09:24:44-0500
Unfortunately, your question requires a lot of work and cannot be done for free. Submit it with all requirements as an assignment to our control panel and we'll assist you.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment