Problem

Extend the watermelon projectile computation program of Exercise 30 on page 362 so the o...

Extend the watermelon projectile computation program of Exercise 30 on page 362 so the output is saved to a file. Which file format would you use for the program, a binary file or a text file? Or would you consider using an array to keep the (x, y) coordinates and save this array by using an object I/O?

Reference Exercise 30 on page 362.

Instead of dropping a watermelon from a building, let’s shoot it from a cannon and compute its projectile. The (x, y) coordinates of a watermelon at time t are

where g is the acceleration of gravity, V is the initial velocity, and (alpha) is the initial angle. The acceleration of gravity on earth is 9.8 m/s2.

Write an application that inputs an initial velocity V (m/s) and an initial angle alpha (degrees) and computes the projectile of a watermelon cannon ball. The program should repeat the computation until the user wants to quit. The program outputs the (x, y) oordinate value for every second, that is, t = 0, 1, 2, and so forth. The program stops the output when the y value becomes 0 or less. To use the cos and sin methods of the Math class, don’t forget that you have to convert the input angle given in degrees to radians. You can convert a degree to equivalent radians by using the following

or calling the toRadians method of the Math class. Note: Air resistance is not considered in the formula. Also, we assumed the watermelon will not get smashed upon firing.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12