Java Reference
In-Depth Information
velocity does not change. In the y-direction the gravitational force
takes its toll. Repeat the simulation from the previous exercise, but
update the x and y components of the location and the velocity
separately. In every iteration, plot the location of the cannonball on the
graphics display as a tiny circle. Repeat until the cannonball has
reached the earth again.
This kind of problem is of historical interest. The first computers were
designed to carry out just such ballistic calculations, taking into
account the diminishing gravity for high-flying projectiles and wind
speeds.
΢G Exercise P6.15. Write a graphical application that displays a checkerboard
with 64 squares, alternating white and black.
΢΢G Exercise P6.16. Write a graphical application that prompts a user to
enter a number n and that draws n circles with random diameter and
random location. The circles should be completely contained inside the
window.
΢΢΢G Exercise P6.17. Write a graphical application that draws a spiral, such
as the following:
283
284
΢΢G Exercise P6.18. It is easy and fun to draw graphs of curves with the Java
graphics library. Simply draw 100 line segments joining the points (x,
f(x)) and (x + d, f(x + d)), where x ranges from x min to x max and d = (x max
Search WWH ::




Custom Search