Java Reference
In-Depth Information
T ABLE 10.1
2001 United States Federal Personal Tax Rates
Tax
rate
Married filing jointly
or qualifying widow(er)
Married filing
separately
Single filers
Head of household
Up to $27,050
Up to $45,200
Up to $22,600
Up to $36,250
15%
27.5%
$27,051-$65,550
$45,201-$109,250
$22,601-$54,625
$36,251-$93,650
30.5%
$65,551-$136,750
$109,251-$166,500
$54,626-$83,250
$93,651-$151,650
35.5%
$136,751-$297,350
$166,501-$297,350
$83,251-$148,675
$151,651-$297,350
39.1%
$297,351 or more
$297,351 or more
$ 148,676 or more
$297,351 or more
*10.10
( Game: The GuessDate class ) Modify the GuessDate class in Listing 10.10.
Instead of representing dates in a three-dimensional array, use five two-dimensional
arrays to represent the five sets of numbers. Thus, you need to declare:
private static int [][] set1 = {{ 1 , 3 , 5 , 7 }, ... };
private static int [][] set2 = {{ 2 , 3 , 6 , 7 }, ... };
private static int [][] set3 = {{ 4 , 5 , 6 , 7 }, ... };
private static int [][] set4 = {{ 8 , 9 , 10 , 11 }, ... };
private static int [][] set5 = {{ 16 , 17 , 18 , 19 }, ... };
*10.11
( Geometry: The Circle2D class ) Define the Circle2D class that contains:
Two double data fields named x and y that specify the center of the circle with
get methods.
A data field radius with a get method.
A no-arg constructor that creates a default circle with ( 0 , 0 ) for ( x , y ) and 1 for
radius .
A constructor that creates a circle with the specified x , y , and radius .
A method getArea() that returns the area of the circle.
A method getPerimeter() that returns the perimeter of the circle.
A method contains(double x, double y) that returns true if the speci-
fied point ( x , y ) is inside this circle (see Figure 10.15a).
A method contains(Circle2D circle) that returns true if the specified
circle is inside this circle (see Figure 10.15b).
A method overlaps(Circle2D circle) that returns true if the specified
circle overlaps with this circle (see Figure 10.15c).
p
(a)
(b)
(c)
F IGURE 10.15 (a) A point is inside the circle. (b) A circle is inside another circle. (c) A circle
overlaps another circle.
Draw the UML diagram for the class and then implement the class. Write a test
program that creates a Circle2D object c1 ( new Circle2D(2, 2, 5.5) ), dis-
plays its area and perimeter, and displays the result of c1.contains(3, 3) ,
c1.contains(new Circle2D(4, 5, 10.5)) , and c1.overlaps(new
Circle2D(3, 5, 2.3)) .
 
Search WWH ::




Custom Search