In: Computer Science
Consider a nuclear reactor whose temperature is monitored by three sensors. An alarm should go off if any two of the sensor readings disagree by more than 5°F. Write a program that would print a string ‘ALARM’ if any two temperate readings disagree by strictly more than 5°F and ‘NORMAL’ otherwise
Ask for each temperature input and display the state
Use MATLAB
Please let me know if anything is required. Follow the indentation as shown in screenshot.
Code:
printf("Enter Three Temperatures in farenheit : \n")
prompt = ''; %taking the temperature inputs from the user
x1 = input(prompt)
x2 = input(prompt)
x3 = input(prompt)
%conditions for the Alarm if any two temperate readings disagree by
strictly more than 5°F
if( (x1 > 5) && (x2 >5))
printf("ALARM\n")
elseif ((x1 > 5) &&(x3 > 5))
printf("ALARM\n")
elseif((x2 > 5) && (x3 > 5))
printf("ALARM\n")
else
printf("NORMAL\n") %‘NORMAL’ otherwise
end
Code :
TestCase 1 :
TestCase 2 :
TestCase 3 :