Java Reference
In-Depth Information
on the left has three segments of height 4 and the one on the right has two segments of height 5:
* *
*** ***
***** *****
******* *******
*** *********
***** ***
******* *****
********* *******
***** *********
******* ***********
********* *
*********** *
* *******
*
*******
2. A certain bank offers 6.5% interest on savings accounts, compounded annually. Create a table that shows how much
money a person will accumulate over a period of 25 years, assuming that the person makes an initial investment of
$1000 and deposits $100 each year after the first. Your table should indicate for each year the current balance, the
interest, the new deposit, and the new balance.
3. Write a program that shows the total number of presents that the person in the song “The Twelve Days of Christmas”
received on each day, as indicated in Table 3.5.
Table 3.5
Twelve Days of Christmas
Day
Presents Received
Total Presents
1
1
1
2
2
3
3
3
6
4
4
10
5
5
15
. . .
. . .
. . .
4. Write a program that prompts for the lengths of the sides of a triangle and reports the three angles.
5. Write a program that computes the spherical distance between two points on the surface of the Earth, given their
latitudes and longitudes. This is a useful operation because it tells you how far apart two cities are if you multiply the
distance by the radius of the Earth, which is roughly 6372.795 km.
Let
1 ,
l
1 , and
2 ,
l
2 be the latitude and longitude of two points, respectively.
Δ
l
, the longitudinal difference,
and
Δσ
, the angular difference/distance in radians, can be determined as follows from the spherical law of cosines:
1 sin
2 + cos
1 cos
2 cos
σ
= arccos(sin
)
For example, consider the latitude and longitude of two major cities:
• Nashville, TN: N 36°7.2
, W 86°40.2
• Los Angeles, CA: N 33°56.4
, W 118°24.0
Search WWH ::




Custom Search