Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2- Create a program to determine whether a user-specified altitude [meter] is in

ID: 2998357 • Letter: 2

Question

2- Create a program to determine whether a user-specified altitude [meter] is in the troposphere, lower stratosphere, or upper stratosphere. The program should include a check to ensure the user a positive value. If a non-positive value entered, the program should inform the user of the error and terminate. If a positive value is entered, the program should calculate and report the resulting temperature in units of degrees Celsius [C] and pressure in units of kilopascals [kPa]. Sample Input/Output

Altitude= 500

An altitude of 500 is in the troposphere with a temprature of 12 degrees C and pressure of 96kPa.

Explanation / Answer

h=input('please enter the height in meters ');
if h<0
disp(' height should be positive ');
end
if (((h>0)+(h==0))*(h<12000))
[T, a, P, rho] = atmosisa(h);
T=T-273;
P=P/1000;
fprintf('An altitude of %.2f is in the troposphere with a temprature of %.3f degrees C and pressure of %.2fkPa.',h, T ,P);
end
if (((h>12000)+(h==12000))*(h<31000))
[T, a, P, rho] = atmosisa(h);
T=T-273;
P=P/1000;
fprintf('An altitude of %.2f is in the lower stratosphere with a temprature of %.3f degrees C and pressure of %.2fkPa.',h ,T ,P);
end
if (((h>31000)+(h==31000))*(h<50000))
[T, a, P, rho] = atmosisa(h);
T=T-273;
P=P/1000;
fprintf('An altitude of %.2f is in the upper stratosphere with a temprature of %.3f degrees C and pressure of %.2fkPa.',h, T, P);
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote