%ascorrea

%program to calculate required cl. valid up till 82345 ft
%from www.grc.nasa.gov/WWW/K-12/airplane/atmos.html

alt=input('Altitude (ft): ');
s=input('Input Wing Planform Area (sq.ft.): ');
v_mach=input('Input speed (Mach): ');
lift=input('Input required lift: ');
eloverdee=input('Input L/D requirement: ');

if alt < 36152
temp=59-.00356*alt;
press=2116*((temp+459.7)/518.6)^5.256;

elseif alt < 82345
    temp=-70;
    press=473.1*exp(1.73-.000048*alt);
    
else
    print('Program Not Valid for given altitude')
end

density=press/(1718*(temp+459.7));
v_fps=v_mach*sqrt(1.4*1718*(temp+459.7));
q=.5*density*v_fps^2;

cl_req=lift/(q*s);
fprintf('Cl_req: %f\n', cl_req);
cd_req=cl_req/eloverdee;
fprintf('Cd_req: %f\n', cd_req);
