Answer to Question #33427 in Java | JSP | JSF for Jimbo

Question #33427
Write an AreaTester program that constructs a Rectangle object and then computes and prints its area. Use the getWidth and getHeight methods. Also print the unexpected answer.
1
Expert's answer
2013-07-23T09:24:34-0400
public class Rectangle {

private double width;
private double hight;

Rectangle(double width, double hight){
this.width= width;
this.hight= hight;
}

publicdouble getWidth() {
returnwidth;
}

publicdouble getHight() {
returnhight;
}

}

public class AreaTester {
publicstatic void main(String[] args) {
Rectanglerectangle = new Rectangle(13.0, 5.9);
doublearea = rectangle.getWidth() * rectangle.getHight();
System.out.println(area);
}
}

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