Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 21st, 2010 | Syntax: Java | Size: 0.44 KB | Hits: 84 | Expires: Never
Copy text to clipboard
  1. import java.awt.Rectangle;
  2.  
  3. public class RectangleCenter
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         Rectangle box = new Rectangle(75, 75, 50, 50);
  8.         double xCoord = box.getCenterX();
  9.         double yCoord = box.getCenterY();
  10.         double rectangleWidth = box.getWidth();
  11.         System.out.println("The center of this rectangle is at: (" + xCoord + ", " + yCoord + ")" + "It's width is: " + rectangleWidth);
  12.     }
  13. }