Java Reference
In-Depth Information
Enter the number of years:
The population in 5 years is 325932970
5
2.12
(
Physics: finding runway length
) Given an airplane's acceleration
a
and take-off
speed
v,
you can compute the minimum runway length needed for an airplane to
take off using the following formula:
v
2
2
a
length
=
Write a program that prompts the user to enter
v
in meters/second (m/s) and the
acceleration
a
in meters/second squared
(m/s
2
),
and displays the minimum runway
length. Here is a sample run:
Enter speed and acceleration:
The minimum runway length for this airplane is 514.286
60 3.5
**2.13
(
Financial application: compound value
) Suppose you save
$100
each
month
into a savings account with the annual interest rate 5%. Thus, the monthly inter-
est rate is
0.05/12
=
0.00417.
After the first month, the value in the account
becomes
100 * (1 + 0.00417) = 100.417
After the second month, the value in the account becomes
(100 + 100.417) * (1 + 0.00417) = 201.252
After the third month, the value in the account becomes
(100 + 201.252) * (1 + 0.00417) = 302.507
and so on.
Write a program that prompts the user to enter a monthly saving amount and dis-
plays the account value after the sixth month. (In Exercise 4.30, you will use a
loop to simplify the code and display the account value for any month.)
Enter the monthly saving amount:
After the sixth month, the account value is $608.81
100
*2.14
(
Health application: computing BMI
) Body Mass Index (BMI) is a measure of
health on weight. It can be calculated by taking your weight in kilograms and
dividing by the square of your height in meters. Write a program that prompts the
user to enter a weight in pounds and height in inches and displays the BMI. Note
that one pound is
0.45359237
kilograms and one inch is
0.0254
meters. Here is
a sample run:
VideoNote
Compute BMI