Gray Bee

Greenhorn
+ Follow
since Sep 21, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gray Bee

Thanks, but never mind, I figured it out finally.
13 years ago
Hi, I'm in my first programming class and I'm having some trouble with part of this assignment. We have to construct concentric rectangles and take the area of the path between then (just subtract the larger from the smaller areas), and then take the diagonals of the rectangles. I have them constructed, but I'm not sure of the syntax for the math operations. Here is the code I have so far.

public static void main (String[] args) {

Rectangle box = new Rectangle(45,55,100,80);
Rectangle box2 = new Rectangle ((int) box.getX()+10, (int)box.getY()+10, (int)box.getWidth()-20, (int) box.getHeight()-20);

System.out.printf("The coordinates of the bigger rectangle are: {(%.0f,%.0f), (%.0f,%.0f),(%.0f,%.0f), (%.0f,%.0f)}%n",
box.getX(), box.getY(), box.getX()+box.getWidth(), box.getY(),
box.getX()+box.getWidth(), box.getY()+box.getHeight(),
box.getX(), box.getY()+box.getHeight());
System.out.printf("The coordinates of the smaller rectangle are: {(%.0f,%.0f), (%.0f,%.0f),(%.0f,%.0f), (%.0f,%.0f)}%n",
box2.getX(), box2.getY(), box2.getX()+box2.getWidth(), box2.getY(),
box2.getX()+box2.getWidth(), box2.getY()+box2.getHeight(),
box2.getX(), box2.getY()+box2.getHeight());


Any help would be appreciated, thanks!
13 years ago