% The ?target? game % Author: F. P. Schloerb % set parameters for calculation g = 9.8; %grav. acceleration v0 = 100; %initial velocity tolerance = 0.1; % tolerance for a hit % randomly select the target distance. rand('state',sum(100*clock)); % seeds random number etrue = rand()*pi/2; dtrue = cannon_ball_distance(etrue, g, v0); % challenge the player fprintf('Select cannon elevation to hit the target!\n'); fprintf('NOTE: g=%3.1f m/s/s; v= %6.1f m/s\n',g,v0); fprintf('The target distance is: %f m\n',dtrue); % now prompt the player for guesses KeepTrying = true; while (KeepTrying) e = input('Enter Elevation Angle (deg.): '); e = e*pi/180; %convert to radians d = cannon_ball_distance(e, g, v0); if (abs(d-dtrue)