Answer to Question #20876 in Java | JSP | JSF for david kumordzi

Question #20876
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.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS