Java Reference
In-Depth Information
week. Be sure to accept fractional hours. Compute the pay. Any overtime
work (over 40 hours per week) is paid at 150 percent of the regular wage.
Solve this problem by implementing a class Paycheck .
΢΢ Exercise P5.14 Write a unit conversion program that asks users to identify
the unit from which they want to convert and the unit to which they want
to convert. Legal units are in, ft, mi, mm, cm, m, and km. Define two
objects of a class UnitConverter that convert between meters and a
given unit.
Convert from:
in
Convert to:
mm
Value:
10
10 in = 254 mm
223
224
΢΢΢ Exercise P5.15. A line in the plane can be specified in various ways:
ȗ
by giving a point (x, y) and a slope m
ȗ
by giving two points (x 1 , y 1 ), (x 2 , y 2 )
ȗ
as an equation in slope-intercept form y = mx + b
ȗ
as an equation x = a if the line is vertical
Implement a class Line with four constructors, corresponding to the
four cases above. Implement methods
boolean intersects(Line other)
boolean equals(Line other)
boolean isParallel (Line other)
΢΢G Exercise P5.16. Write a program that draws a circle with radius 100 and
center (200, 200). Ask the user to specify the x- and y-coordinates of a
point. Draw the point as a small circle. If the point lies inside the circle,
color the small circle green. Otherwise, color it red. In your exercise,
define a class Circle and a method boolean
isInside(Point2D.Double p) .
Search WWH ::




Custom Search