Java Reference
In-Depth Information
1.8
(
Area and perimeter of a circle
) Write a program that displays the area and
perimeter of a circle that has a radius of
5.5
using the following formula:
perimeter
=
2
*
radius
* p
area
=
radius
*
radius
* p
1.9
(
Area and perimeter of a rectangle
) Write a program that displays the area and
perimeter of a rectangle with the width of
4.5
and height of
7.9
using the follow-
ing formula:
area
=
width
*
height
1.10
(
Average speed in miles
) Assume a runner runs
14
kilometers in
45
minutes and
30
seconds. Write a program that displays the average speed in miles per hour.
(Note that
1
mile is
1.6
kilometers.)
*
1.11
(
Population projection
) The U.S. Census Bureau projects population based on the
following assumptions:
■
One birth every 7 seconds
■
One death every 13 seconds
■
One new immigrant every 45 seconds
Write a program to display the population for each of the next five years. Assume
the current population is 312,032,486 and one year has 365 days.
Hint
: In Java, if
two integers perform division, the result is an integer. The fraction part is trun-
cated. For example,
5
/
4
is
1
(not
1.25
) and
10
/
4
is
2
(not
2.5
).
1.12
(
Average speed in kilometers
) Assume a runner runs
24
miles in
1
hour,
40
minutes,
and
35
seconds. Write a program that displays the average speed in kilometers per
hour. (Note that
1
mile is
1.6
kilometers.)