Exercise 2:The following statements are intended to alert the user of the body t
ID: 642374 • Letter: E
Question
Exercise 2:The following statements are intended to alert the user of the body temperature standards in degrees Celsius. Explain what is wrong with this construct. Hint: try this construct with different values of temp (36, 39 and 45) and see what answers you get. Fix it so that it displays the proper temperature range. temp= input( ?enter temperature in Celsius?) if temp = 36.2 disp( ?temp is normal?); Else if temp > = 37.3 disp( ?temp slightly high?); Else if temp > = 38.5 Disp ( ?temp high?); Else if temp >?40 Disp ( ?temp too high, seek medical attention?); endExplanation / Answer
% first we have to consider higheset followed by next in descending order so below code works for all conditions.
temp = input('enter temperature in celsius');
if temp>=40
disp('temp is too high, seek medical attention');
elseif temp>=38.5
disp('temp high');
elseif temp>=37.3
disp('temp slightly high');
elseif temp>=36.2
disp('temp is normal');
elseif temp<36.2
disp('temp is too high, seek medical attention');
end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.