Tracing separate temperature decisions

A thermal test script assigns a dimensionless inspection score from a scalar temperature reading. Run the following MATLAB code separately for each temperature in the table, starting with score = 0 every time. Enter the final score as an exact integer.


MATLAB
score = 0;
if temperature > 60
    score = score + 2;
end
if temperature > 80
    score = score + 5;
else
    score = score - 1;
end


The variable temperature contains the numerical reading in °C.

Temperature (°C)Final score
45
70
90

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Conditional Statements and Loops Questions: