Question: JAVA Write a program with the class Skydive that calculates the velocity of a skydiver as a functionoftime. The main program will include a loop
JAVA
Write a program with the class Skydive that calculates the velocity of a skydiver as a functionoftime. The main program will include a loop that allows you to enter in the specications for more than one jump. Newtons Second Law has two forces you have to account for: Ftot = ma = Fgravity Fdrag where m is the mass (kg) and a is the acceleration (m/s2) of the skydiver. Note, in that in this and subsequent equations, we will assume that the positive x-direction (and thus the positive velocity and acceleration) points down towards the ground. Fdrag = (1/2) CAav2 where C is the drag coefcient (unitless), A is the cross-sectional area (m2), a is the air density (kg/m3), and v is the velocity (m/s). Going back to Newtons Second Law, we can plug in for Fdrag to find: Ftot = ma = Fgravity Fdrag = mg - (1/2) CAav2 a = g [(CaA) / 2m] (v2) Note this means that the acceleration at any given moment in time is determined by the velocity at any given moment in time. That is: a(t) = g [(CaA) / 2m] (v(t)2) The velocity at time t, in general, can be given as: v(t) = v(tt) + a(tt)t where t isasmallbitoftime. Applyingthistothespeciccaseoftheskydiver,wecansubstitute in for a(tt) using the a(t) equation before it, namely: (t) = v(tt) +( g - [(CaA) / 2m] v(tt)2t ) But what this equation tells us is that the velocity at time t depends on the velocity at time tt. And the velocity at time tt depends on the velocity at time t2t, and so on. This is why we need to use the computer, because in order to calculate the velocity at the current time t you have to rst calculate the velocities at all intermediate bits of time prior to t. Your program should ask you to enter in the mass, cross-sectional area, and drag coefcient of the skydiver. Your program should also ask how long do you want to calculate the dive out to and what your timestep (t) will be. You can assume the density of air is 1.14 kg/m3 and gravitational acceleration is 9.81 m/s2. As your program does its calculations, it should save the time and velocities in an array (i.e., in two separate one-dimensional arrays, one for time and the other for velocities). One you have calculated all these values, write the output to a le. The le should have two columns, the rst being the time (t) and the second being the velocity (v(t)) at that time. You can separate the two columns either by a space, tab, or comma; Excel can import les whose columns are separated by any of those characters. Your program, then, should also prompt you for the output filename. While the full output will go to a le, you should write out a few values to screen, so you can see how youre doing. Below is example console output: Enter the mass of the skydiver (kg): 80 Enter the cross-sectional area of the skydiver (m2): 1.035 Enter the drag coefficient of the skydiver: 0.581 Enter the ending time (sec): 16 Enter the time step (sec): 0.1 Enter the output filename: soln.csv Writing out file. Here are the first few lines: 0.100, 0.981 0.200, 1.9616 0.300, 2.9409 0.400, 3.9182 0.500, 4.8927 0.600, 5.8634 0.700, 6.8297 0.800, 7.7907 0.900, 8.7457 Enter another dive? (y/[n]): n
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
