10. Write a program to calculate a temperature provided by the user into a diffe
ID: 3736460 • Letter: 1
Question
10. Write a program to calculate a temperature provided by the user into a different unit system. The program should ask the user to enter a temperature in units of degrees Fahrenheit. The program should then ask the user to choose a unit system they would like to have the value converted into, using a menu. The menu should display the choices "deg C", "K", and "deg R", which should be stored in a cell array. The program should display the output in a sentence formatted as shown below. The actual values in the sentence should change appropriately as the user input and menu selection changes. Choose a final unit deg C deg RExplanation / Answer
%you havent provided the full question, but i searched for it and got the full one. So here is the code
%%%%
%a
m={'deg C' ,'K','deg R'};
t=input('Enter the temperature [deg F]: ');
choice=menu('Choose a final unit',m);
newT=[(t-32)/1.8;(t+459.67)*5/9;t+459.67];
fprintf('The equivalent temperature to %i deg F is %i %s. ',t,round(newT(choice)),m{choice})
%%%%%
%b
m={'deg C' ,'K','deg R'};
t=input('Enter the temperature [deg F]: ');
choice=menu('Choose a final unit',m);
conversion={@(t)(t-32)/1.8;@(t)(t+459.67)*(5/9);@(t)t+459.67};
newT=conversion{choice}(t);
fprintf('The equivalent temperature to %i deg F is %i %s. ',t,round(newT),m{choice})
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.