RectangleTest.java
URL: http://nunnone.com
This is a test driver class. It instantiates a few rectangles with varying lengths and widths and then prints their areas and perimeters.
What is odd is the output I get from NetBeans for the "stupid" rectangle. The program prints its value as "1280.3200000000002".
Copy this code and paste it in your HTML
public class RectangleTest {
public static void main
(String[] args
) {
System.
out.
println("Small rectangle: A=" + small.
getArea() + " P="+small.
getPerimeter());
System.
out.
println("Default rectangle: A=" + noArgs.
getArea() + " P="+noArgs.
getPerimeter());
System.
out.
println("Large rectangle: A=" + large.
getArea() + " P="+large.
getPerimeter());
System.
out.
println("Rectangle not written as double: A=" + notDouble.
getArea() + " P="+notDouble.
getPerimeter());
System.
out.
println("Stupidly proportioned rectangle: A=" + stupid.
getArea() + " P="+stupid.
getPerimeter());
}
}
Report this snippet