(*Thisprogramistofindtheanglecannonneedtofiretohittheship*)(*Case1-firstneedthetimeneedforcannonballtoreachtheship*)(*inputpart*)f[x_]=Cos[x];y[x_]=Cos[x];v=82*f[x_];(*vishorizontalvelocity*)u=82*y[x_];(*uistheverticalvelocity*)hd=560;(*distancetoshipfromthecannon*)g=9.8;(*gisthegravity*)(*Itaketimetoreachshipastandangletofireasa*)(*CalculationPart*)eq01=hdv*t1;(*Obtaintheequation*)t=Solve[eq01,t1];(*Outputpart*)Print["when the cannon is fired"]Print["(a) equation for the horizontal distance: ",eq01]Print["(b) equation for the time: ",t]
when the cannon is fired
(a) equation for the horizontal distance: 56082t1Cos[x_]
(b) equation for the time: t1
280Sec[x_]
41
In[]:=
(*Case2-Nowtofindtheangle*)(*inputpart*)s=0;(*Whencannonballhitstheshipverticledisplacement*)(*calculationpart*)eq02=0u*t-(1/2)*g*(t^2);Angleanswer=Solve[eq02,x]//N;(*Outputpart*)Print["Angle that connon need to fire"]Print["(a) equation for the verticle distance: ",eq02]Print["(b) Angle is: ",Angleanswer]
Angle that connon need to fire
(a) equation for the verticle distance: 082Cos[x_]t1-4.9
280Sec[x_]
41
2
t1
280Sec[x_]
41
(b) Angle is: Solve[0.{{82.Cos[x_](t16.82927Sec[x_])-4.9}},x]
2
(t16.82927Sec[x_])
