hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)

dD={1.23*10^(-3),1.01*10^(-3),8.19*10^(-4),6.6*10^(-4),5.26*10^(-4),4.14*10^(-4),8.89*10^(-5),4*10^(-6),3.06*10^(-7),2*10^(-8),4.97*10^(-10),3.39*10^(-12),5.86*10^(-13),1.99*10^(-13),8.04*10^(-14),3.59*10^(-14),6.5*10^(-15),1.58*10^(-15),4.64*10^(-16),1.54*10^(-16)};(*Density*)
hd=Transpose[{hH,dD}];
g11=ListPlot[hd,PlotStyle-> {Red,PointSize[0.02]},PlotRange->All];
f1=Fit[hd,{Exp[-h/8.4]},h]
g12=Plot[f1,{h,hH[[1]],Last[hH]},PlotStyle-> Blue,PlotRange->All];
Show[{g11,g12}]

hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)
mM={28.96,28.96,28.96,28.96,28.96,28.96,28.96,28.96,28.96,28.96,28.88,27.20,26.15,24.98,23.82,22.66,19.94,17.94,16.84,16.17};(*Mean Molecular Weight*)
hM=Transpose[{hH,mM}];
g21=ListPlot[hM,PlotStyle-> {Red,PointSize[0.02]},PlotRange->All];
f2=Fit[hM,{h^5,h^4,h^3,h^2,h,1},h]
g22=Plot[f2,{h,hH[[1]],Last[hH]},PlotStyle-> Blue,PlotRange->All];
Show[{g21,g22}]

hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)
pP={1.01*10^(6),7.95*10^(5),6.17*10^(5),4.72*10^(5),3.57*10^(5),2.65*10^(5),5.53*10^(4),2.87*10^(3),2.25*10^(2),1.04*10^(1),3.01*10^(-1),7.41*10^(-3),2.15*10^(-3),8.58*10^(-4),3.86*10^(-4),1.88*10^(-4),4.03*10^(-5),1.10*10^(-5),3.45*10^(-6),1.19*10^(-6)};(*Pressure*)
hP=Transpose[{hH,pP}];
g31=ListPlot[hP,PlotStyle-> {Red,PointSize[0.02]},PlotRange->All];
f3=Fit[hP,{Exp[-h/8.4]},h]
g32=Plot[f3,{h,hH[[1]],Last[hH]},PlotStyle-> Blue,PlotRange->All];
Show[{g31,g32}]

hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)
mF={6.63*10^(-8),8.07*10^(-8),9.92*10^(-8),1.23*10^(-7),1.55*10^(-7),1.96*10^(-7),9.14*10^(-7),2.03*10^(-5),2.66*10^(-4),4.07*10^(-3),1.63*10^(-1),2.25*10^(1),1.25*10^(2),3.52*10^(2),8.31*10^(2),1.77*10^(3),8.61*10^(3),3.19*10^(4),1.02*10^(5),2.95*10^(5)};(*Mean Free Path*)
hMF=Transpose[{hH,mF}];
g41=ListPlot[hMF,PlotStyle-> {Red,PointSize[0.02]},PlotRange->All];
f4=Fit[hMF,{h^6},h]
g42=Plot[f4,{h,hH[[1]],Last[hH]},PlotStyle-> Blue,PlotRange->All];
Show[{g41,g42}]

hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)
gG={981,980,979,979,978,978,975,968,962,956,951,939,927,916,905,894,868,843,819,796};(*Acceleration Gravity*)
hg=Transpose[{hH,gG}];
g51=ListPlot[hg,PlotStyle-> {Red,PointSize[0.02]},PlotRange->All];
f5=Fit[hg,{h,1},h]
g52=Plot[f5,{h,hH[[1]],Last[hH]},PlotStyle-> Blue,PlotRange->All];
Show[{g51,g52}]

hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)
tT={288,275,262,249,236,223,217,250,256,181,210,714,1156,1294,1374,1432,1487,1499,1506,1508};(*Temperature*)
ht=Transpose[{hH,tT}];
g61=ListPlot[ht,PlotStyle-> {Red,PointSize[0.02]},PlotRange->All];
f6=Fit[ht,{Exp[h],h^5,h^4,h^3,h,1},h]
g62=Plot[f6,{h,hH[[1]],Last[hH]},PlotStyle-> Blue,PlotRange->All];
Show[{g61,g62}]

(* Part by part Modeling *)
hH={0,2,4,6,8,10,20,40,60,80,100,140,180,220,260,300,400,500,600,700};(*Altitude*)
tT={288,275,262,249,236,223,217,250,256,181,210,714,1156,1294,1374,1432,1487,1499,1506,1508};(*Temperature*)
ttT=Transpose[{hH,tT}];
TableForm[ttT]
ttT1=Take[ttT,11]
g11=ListPlot[ttT1,PlotStyle->{Blue,PointSize[0.01]},PlotRange->All];
fttT1=Fit[ttT1,{h^5,h^4,h^2,h^2,h,1},h];
g21=Plot[fttT1,{h,hH[[1]],hH[[11]]},PlotStyle->Green];
Show[{g11,g21},PlotRange->All];
ttT2=Take[ttT,-10];
g12=ListPlot[ttT2,PlotStyle->{Magenta,PointSize[0.01]},PlotRange->All];
fttT2=Fit[ttT2,{h^5,h^4,h^2,h^2,h,1},h];
g22=Plot[fttT2,{h,hH[[11]],Last[hH]},PlotStyle->Brown,PlotRange->All];
Show[{g12,g22},PlotRange->All];
Show[{g11,g21,g12,g22},PlotRange->All]

hHH=Input["Enter the corresponding altitude in km "]
tTTT=If[hHH<hH[[11]],fttT1/.h->hHH,fttT2/.h->hHH]
Print["Temperature of the corresponding altitude", hHH," km "," is ", tTTT," Celcius"]