Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA Write a program with the class Skydive that calculates the velocity of a sk

ID: 3834785 • Letter: J

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 that allows you to enter in the specications for more than one jump.

Newton’s 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 Newton’s Second Law, we can plug in for Fdrag to nd:
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 lename.

While the full output will go to a le, you should write out a few values to screen, so you can see how you’re doing. Below is example console output:
Enter the mass of the skydiver (kg): 80
Enter the cross-sectional area of the skydiver (mˆ2): 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

Finally, there should be at least one method that you write that can be used to provide output for tracing variables: The method should be called test-something, e.g., testStatistics. Somewhere in your program, there should be a call to that method. In the code you submit, that call should be commented out.

Explanation / Answer

public double calculateVelocity(double time){
double velocity;
velocity = calculateVelocity(time - timeStep)
+ (acceleration - ((drag * crossArea * airDensity)
/ (2 * massOfPerson))
* (calculateVelocity(time - timeStep)*(time * timeStep)))
* timeStep;
}
return velocity;
}
public void assignVelocitytoArrays(){
double currentTime = 0;   
while(currentTime <= endingTime){
this.vFinal = calculateVelocity(currentTime);
currentTime += timeStep;
}
}   
if (time - timeStep > 0)
{
calculateVelocity(time - timeStep) + the rest of the code
}
else return velocity;
calculateVelocity((time - timeStep)*(time - timeStep))
if(input value == starting point){
return starting point
}
else{
follow the rule
}
double[] v = new double[maxTime/timeStep];
v[0] = 0; //starting point
for(int t = 1; t < maxSteps; t++){
v[t] = v[t-1] + (g - [(drag x crossArea x airDensity) / (2*mass)] * v[t-1]^2 ) * (t)
}