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.
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!
Learn more about our help with Assignments:
JavaJSPJSF