(*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=hdv*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: 56082t1Cos[x_]
(b) equation for the time: t1
280Sec[x_]
41

In[]:=
(*Case2-Nowtofindtheangle*)​​​​(*inputpart*)​​s=0;(*Whencannonballhitstheshipverticledisplacement*)​​​​(*calculationpart*)​​eq02=0u*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]
Pattern
:First element in pattern Pattern[System`TSolveDump`X$2494[1],_] is not a valid pattern name.
Pattern
:First element in pattern Pattern[System`TSolveDump`X$2494[1],_] is not a valid pattern name.
Pattern
:First element in pattern Pattern[System`TSolveDump`X$2494[1],_] is not a valid pattern name.
General
:Further output of Pattern::patvar will be suppressed during this calculation.
Solve
:Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help.
Solve
:Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help.
Angle that connon need to fire
(a) equation for the verticle distance: 082Cos[x_]t1
280Sec[x_]
41
-4.9
2
t1
280Sec[x_]
41

(b) Angle is: Solve[0.{{82.Cos[x_](t16.82927Sec[x_])-4.9
2
(t16.82927Sec[x_])
}},x]