Write a script called prtemps that will prompt the user for a maximum Celsius value in the range from -16 to 20; error-check to make sure it’s in that range
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:5| Question number:25.5
All Answers
total answers (1)
prtemps.m
% Prompt for a maximum C temperature and print a table
% showing degrees C and degrees F
fprintf('When prompted, enter a temp in degrees C in')
fprintf(' range -16\n to 20.\n')
maxtemp = input('Enter a maximum temp: ');
% Error-check
while maxtemp < -16 || maxtemp > 20
maxtemp = input('Error! Enter a maximum temp: ');
end
% Print table include headers
fprintf(' F C\n');
f = 0;
c = 5/9*(f-32);
while (c <= maxtemp)
fprintf('%6.1f %6.1f\n',f,c)
f = f + 5;
c = 5/9*(f-32);
end
need an explanation for this answer? contact us directly to get an explanation for this answer