Java Reference
In-Depth Information
2.9
( Physics: acceleration ) Average acceleration is defined as the change of velocity
divided by the time taken to make the change, as shown in the following formula:
v 1
-
v 0
a
=
t
Write a program that prompts the user to enter the starting velocity v 0 in meters/
second, the ending velocity v 1 in meters/second, and the time span t in seconds,
and displays the average acceleration. Here is a sample run:
Enter v0, v1, and t: 5.5 50.9 4.5
The average acceleration is 10.0889
2.10
( Science: calculating energy ) Write a program that calculates the energy needed
to heat water from an initial temperature to a final temperature. Your program
should prompt the user to enter the amount of water in kilograms and the initial
and final temperatures of the water. The formula to compute the energy is
Q = M * (finalTemperature - initialTemperature) * 4184
where M is the weight of water in kilograms, temperatures are in degrees Celsius,
and energy Q is measured in joules. Here is a sample run:
Enter the amount of water in kilograms: 55.5
Enter the initial temperature: 3.5
Enter the final temperature: 10.5
The energy needed is 1625484.0
2.11
( Population projection ) Rewrite Programming Exercise 1.11 to prompt the user
to enter the number of years and displays the population after the number of years.
Use the hint in Programming Exercise 1.11 for this program. The population
should be cast into an integer. Here is a sample run of the program:
Enter the number of years: 5
The population in 5 years is 325932970
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
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 run-
way length. Here is a sample run:
length
=
Enter speed and acceleration: 60 3.5
The minimum runway length for this airplane is 514.286
 
Search WWH ::




Custom Search