Fall Semester 2009


Homework Three
Problem 1 Write a program that

Here's how my program works:

-bash-3.1$ javac Four.java
-bash-3.1$ java Four 3 2 4 1 6 7 4
1 2 3 4 4 6 7 
-bash-3.1$ java Four 8 5 4 3 2 1
1 2 3 4 5 8 
-bash-3.1$ java Four 4 2 3 1 6 6 6
1 2 3 4 6 6 6 
-bash-3.1$ java Four 9 1 9 2 9 3 
1 2 3 9 9 9 
-bash-3.1$ java Four 9 3 9 2 9 1
1 2 3 9 9 9 
-bash-3.1$ 

Problem 2 Write a program that

The descriptions are for circles and rectangles at least.

Here's how a circle is requested:

circle <x-coordinate> <y-coordinate> radius <radius-size>

Here's how a rectangle is requested:

rectangle <x-coordinate> <y-coordinate> size <width-size> <height-size>

Here's how my program works (see actual examples of data):

-bash-3.1$ java Five
Welcome, please define your first object: circle 2 3 radius 10

Adding Circle at (2.0, 3.0) radius 10 and area 314.1592653589793
Please enter another object or done if finished: rectangle -1 2 size 2 4
Adding Rectangle at (-1.0, 2.0) width: 2.0, height: 4.0, and area 8.0
Please enter another object or done if finished: circle 9 1 radius 8
Adding Circle at (9.0, 1.0) radius 8 and area 201.06192982974676
Please enter another object or done if finished: rectangle 2 8 size 12 8
Adding Rectangle at (2.0, 8.0) width: 12.0, height: 8.0, and area 96.0

Please enter another object or done if finished: circle 0 0 radius 12
Adding Circle at (0.0, 0.0) radius 12 and area 452.3893421169302
Please enter another object or done if finished: done
Rectangle at (-1.0, 2.0) width: 2.0, height: 4.0, and area 8.0
Rectangle at (2.0, 8.0) width: 12.0, height: 8.0, and area 96.0
Circle at (9.0, 1.0) radius 8 and area 201.06192982974676
Circle at (2.0, 3.0) radius 10 and area 314.1592653589793
Circle at (0.0, 0.0) radius 12 and area 452.3893421169302
-bash-3.1$

You have complete freedom on how you approach this.

For maximum credit you would:

Best of luck, let me know if you need any help.


Updated by Adrian German for A202/A598, A290/A590