Write a script to determin and display the equivalant pressure in the atmosphere
ID: 3554153 • Letter: W
Question
Write a script to determin and display the equivalant pressure in the atmospheres and psi for an inputted value of bars. Prompt the user for the pressure in bars and display the pressure in atmospheres and psi. Check the input to make sure it is greater than 0.
The conversion must be done in a function. The function will accept the pressure in bars and return both atmospheres and psi. Your script should continue to prompt the user to see if they wish to another calculation.
1 bar= 0.9869 atm= 14.504 psi
Explanation / Answer
while(1)
pBar=input('enter the pressue value: ');
% Atm: standard atmospheric pressure (unit: 101325 Pa or 101325 Nm^-2)
% Bars: pressure above ambient or atmospheric pressure (100000 Nm^-2)
% PSI: pound per square inch (1 lb/in^2 or 6894.757293168 Nm^-2)
pPa=pBar * (100000); %10^5
pAtm=pPa * (9.86923266716013e-006); %1/101325
pPSI=pPa * (1.450377/10000); % 1.450377*10^-4
x=sprintf('the equivalent pressure in atmospheres is %f and in psi is %f ',pAtm,pPSI);
disp(x);
option=input('enter 1 if you want to do again else enter 0: ');
if(option ==1)
continue;
else
break
end
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.